Skip to content
Permalink
Browse files

PsrToTracyLoggerAdapter: changed the log message

Some loggers may require a non-empty log message. Adding the exception
class, code and file to the log message solves this issue.
  • Loading branch information...
petaak authored and dg committed May 23, 2019
1 parent 7641fee commit 45349ccc1c86f81789464b55c09e58c02a16e317
Showing with 3 additions and 3 deletions.
  1. +1 −1 src/Bridges/Psr/PsrToTracyLoggerAdapter.php
  2. +2 −2 tests/Tracy.Bridges/PsrToTracyLoggerAdapter.phpt
@@ -41,7 +41,7 @@ public function __construct(Psr\Log\LoggerInterface $psrLogger)
public function log($value, $priority = self::INFO)
{
if ($value instanceof \Throwable) {
$message = $value->getMessage();
$message = Tracy\Helpers::getClass($value) . ': ' . $value->getMessage() . ($value->getCode() ? ' #' . $value->getCode() : '') . ' in ' . $value->getFile() . ':' . $value->getLine();
$context = ['exception' => $value];
} elseif (!is_string($value)) {
@@ -28,7 +28,7 @@ class DummyPsrLogger extends Psr\Log\AbstractLogger
$psrLogger = new DummyPsrLogger;
$tracyLogger = new PsrToTracyLoggerAdapter($psrLogger);
$exception = new \Exception('Something went wrong');
$exception = new \Exception('Something went wrong', 123);
$tracyLogger->log('info');
$tracyLogger->log('warning', ILogger::WARNING);
@@ -41,5 +41,5 @@ Assert::same([
[Psr\Log\LogLevel::WARNING, 'warning', []],
[Psr\Log\LogLevel::INFO, '123', []],
[Psr\Log\LogLevel::INFO, "array (1)\n x => \"y\"", []],
[Psr\Log\LogLevel::INFO, 'Something went wrong', ['exception' => $exception]],
[Psr\Log\LogLevel::INFO, 'Exception: Something went wrong #123 in ' . __DIR__ . DIRECTORY_SEPARATOR . 'PsrToTracyLoggerAdapter.phpt:31', ['exception' => $exception]],
], $psrLogger->entries);

0 comments on commit 45349cc

Please sign in to comment.
You can’t perform that action at this time.