The PHP Framework Interop Group has accepted a standard for the use of a Logger Interface within PHP, the details of which can be read at http://www.php-fig.org/psr/psr-3/.
This standard has been implemented in the Monolog PHP library (https://github.com/Seldaek/monolog).
The monolog library is already used by many libraries, frameworks, and applications globally including Symfony, Composer, Drupal, and countless others. Monolog is also authored and maintained by the author of the PSR3 specification; provides a stable base; and is implemented by many third-party log handlers.
We really should look at doing adding support for PSR3 to Moodle.
This can be done by:
- adding a default configuration for Monolog which uses a console handler to display messages
- replacing the content of mtrace() and debugging() calls with core_logger::info($message); or similar
- deprecating mtrace() and debugging() in the longer term
- allowing override of the default monolog configuration by passing a valid configuration object or class extending the moodle core_logger class.
- Add appropriate logging of all uncaught exceptions and fatal errors
- add logging of all performance metrics without having to parse files (you can send arrays to log handlers rather than having to parse a flat text string as we do now).
This will aid:
- developers in capturing and preserving useful output as you can log individual messages to multiple locations;
- developers and administrators as all exceptions can be caught and logged - allowing for pro-active fixing of issues as they occur (you can also log the complete stacktrace)