It's better when it's simple

User Tools

Site Tools



Intercept or modify logging
Prepare the lines to be written

This event is signalled by log() in inc/Logger.php when a new message is to be logged, handlers can use it to modify the message or change the log location.

Passed Data

The passed data is an associative array with the following keys:

  • facility (string) – the logging facility eg. debug or deprecated
  • datetime (int) – the current timestamp
  • message (string) – the message to be logged
  • details (mixed) – additional details to be logged, needs to be transformed into text before logging
  • file (string) – the file where the data to log was created
  • line (int) – the line in the above file where the data to log was created
  • loglines (array) – the actual lines to be logged. Empty in BEFORE, will be filled by Logger::formatLogLines
  • logfile (string) – the location of the logfile the data will be written to

Data will only be logged if the loglines in non-empty after the AFTER action.

Plugins will probably want to do one of these things:

  • change the log file location:
    • register an AFTER handler, change the logfile event data
  • do not use the built in logging but log somewhere else:
    • register a BEFORE handler, prevent default and do your own logging
  • add additional log info:
    • register an AFTER handler, modify the loglines
  • modify the log format:
    • register a BEFORE handler, prevent default, create the loglines array

See also

devel/event/logger_data_format.txt · Last modified: 2022-01-22 09:08 by andi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki