diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-12-04 07:34:51 +0300 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-12-04 08:02:55 +0300 |
commit | 14cf2581242c75907fb554e08a30041ad107f558 (patch) | |
tree | 9ce5ab8e5547ef90fb238d8cc15250277fa410f5 /core/Log.php | |
parent | ee6554e1d64bf4a4ecf05bfa513a35de8df3ef9e (diff) |
#6622 Logger refactoring: move to PSR-3 compatibility
- keep the log message as string
- exceptions are logged in context under the "exception" key
- Piwik\Error objects are replaced by \ErrorException (logged the PSR-3 way)
Diffstat (limited to 'core/Log.php')
-rw-r--r-- | core/Log.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/Log.php b/core/Log.php index 3f73f5dc24..8bcf91df9c 100644 --- a/core/Log.php +++ b/core/Log.php @@ -117,6 +117,13 @@ class Log extends Singleton const GET_AVAILABLE_WRITERS_EVENT = 'Log.getAvailableWriters'; /** + * The backtrace string to use when testing. + * + * @var string + */ + public static $debugBacktraceForTests; + + /** * Singleton instance. * * @var Log @@ -261,6 +268,12 @@ class Log extends Singleton private function doLog($level, $message, $parameters = array()) { + // To ensure the compatibility with PSR-3, the message must be a string + if ($message instanceof \Exception) { + $parameters['exception'] = $message; + $message = $message->getMessage(); + } + // Create a record similar to Monolog to ease future transition $record = array( 'message' => $message, |