symphonycms/symphony-2 — Issue #852: Save Log file as JSON
Author: brendo
Created: 2011-10-21 08:33:46+00:00
State: open

Symphony current saves Logs as a single line string, which includes a date, message and the line where the error was thrown from. This isn't always as helpful as we'd like, especially if it's an error in the MySQL class. The Logs are fairly simple at the moment, there current nature makes it hard for developers to do 'anything' nice with them (it's a string, no metadata).

A better format for log files would be JSON, which is lightweight and will allow us to save much more information when an error occurs. For example, when Exceptions are logged, we can also log the backtrace to find out the offending code that caused the Exception.

This change should:

- Make the `writeToLog` save a basic JSON array (date, type, message)
- Maintain the current `pushToLog` and `writeToLog` functions, but deprecate them for removal in 2.4
- Introduce a new function for logging (name to be decided), that accepts an array (to be converted as JSON with `json_encode`). At minimum this array should contain a data, type and message
- Update various areas of the Symphony code base to make use of the improved logging and provide more information (`GenericErrorHandler::handler`, `GenericExceptionHandler::handler` can pass the backtrace!)
- On the run of `update.php`, end the existing log file (which will just be the old plaintext kind) and archive it