A MediaWiki bot software traditionally should be able to write a log about what it has done (and this log can be VERY useful). In Apibot this is done through a specific object - the
Log object, contained in the Mains object.
The standard implementation writes into a logfile, whose name is specified in the bot settings. If none given, will try to write in a file in the same directory and with the same name as the starting PHP script, but with a ".log" extension instead of a ".php".
Writing a log entry requires supplying three parameters:
- the string that must be written
- the entry log level (think importance). Default - LL_INFO
- a log preface (which will typically denote the entry info source). Default - none.
By default, Apibot has five log levels:
LL_DEBUG- least important: verbose info that may help to debug a problem
LL_INFO- standard bot messages
LL_WARNING- messages that something strange happened
LL_ERROR- an error occurred (something could not be done, or might be screwed)
LL_PANIC- the most important: a really bad error occurred (one that the bot should typically stop at)
Creating an object of the
Log class requires one parameter:
$params- the object params
$loglevel- will write only entries with loglevel equal to or higher than this one. Default - LL_INFO.
true(default), will echo the log also to the standard output (screen)
$html_log- will format the log output in a way suitable for viewing in a browser
$levelprefs- an array of strings that will be used as a preface for the matching log level in the log output
log ( $message, $loglevel, $preface )- write a line in the bot log