-
Improvement
-
Resolution: Fixed
-
Blocker
-
2.9, 3.7
-
MOODLE_29_STABLE, MOODLE_37_STABLE
-
MOODLE_37_STABLE
-
MDL-49399-master -
The intent of this set of changes is to help with tracking down issues with the site and is a oft-requested feature.
Currently our recommendation is to write cron output to a log file and read it. This isn't really very administrator-friendly and means that failing jobs can go unnoticed for a considerable period.
This set of changes introduces a new task logging system which adds a new output buffer to:
- cron runs (web + CLI)
- scheduled task runs
- adhoc task runs
The output buffer uses a new function which both returns the same buffer (so that it is displayed to the user still), and writes to a filehandle.
This method allows capture of all content displayed via:
- mtrace
- echo
- var_dump
- print_r
- print_object
It does not capture output displayed via fwrite(STDOUT, 'Hidden from logs but displayed in CLI');
If the job itself runs an ob_start then the output of that nested capture is not considered. It does not interfere with any logic within a task.
When the task finishes, the task is sent to a log storage class to store as appropriate.
Filters can be applied at this stage to store all, or only failed jobs.
The functionality can be disabled entirely too.
If the task fails then the state is noted too.
if the task calls die or causes the thread to finish prematurely then this also counts as a fail and is logged. (segfaults are excluded from this).
The change allows for the storage class to be overridden such that a custom storage class can be used. This may be useful for those shipping to somewhere such as fluentd, graylog, etc.
The default implementation stores a range of metadata in the database (start and end time, number of DB queries, result, user that the task ran as for adhoc tasks, etc.). The output is stored in the file storage API.
A cleanup task is also present and used in the default implementation to keep the number of logs to a minimum.
- blocks
-
MDL-64347 Improve processing of scheduled and adhoc tasks
- Closed
- has a non-specific relationship to
-
MDL-64359 Call shutdown handlers on SIGINT/SIGTERM
- Closed
-
MDL-45246 Add exception reporting support
- Closed
- has been marked as being related by
-
MDL-50592 Add PSR3 Logging support to mtrace/debugging/etc.
- Open
-
MDL-68407 Expose an index of the adhoc tasks and their logs
- Closed
- is parent of
-
MDL-67744 Optimize SQL for Task logs page
- Closed
- will help resolve
-
MDL-64842 Log outgoing mail
- Closed
- links to