mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-22 09:06:10 +02:00
Fix displaying anonymous classes
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
namespace Monolog\Formatter;
|
||||
|
||||
use Exception;
|
||||
use Monolog\Registry;
|
||||
|
||||
/**
|
||||
* Normalizes incoming records to remove objects/resources so it's easier to dump to various targets
|
||||
@@ -108,7 +109,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
$value = $this->toJson($data, true);
|
||||
}
|
||||
|
||||
return sprintf("[object] (%s: %s)", get_class($data), $value);
|
||||
return sprintf("[object] (%s: %s)", Registry::getClass($data), $value);
|
||||
}
|
||||
|
||||
if (is_resource($data)) {
|
||||
@@ -122,11 +123,11 @@ class NormalizerFormatter implements FormatterInterface
|
||||
{
|
||||
// TODO 2.0 only check for Throwable
|
||||
if (!$e instanceof Exception && !$e instanceof \Throwable) {
|
||||
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.get_class($e));
|
||||
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Registry::getClass($e));
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'class' => get_class($e),
|
||||
'class' => Registry::getClass($e),
|
||||
'message' => $e->getMessage(),
|
||||
'code' => $e->getCode(),
|
||||
'file' => $e->getFile().':'.$e->getLine(),
|
||||
@@ -159,7 +160,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
// as a class name to avoid any unexpected leak of sensitive information
|
||||
$frame['args'] = array_map(function ($arg) {
|
||||
if (is_object($arg) && !($arg instanceof \DateTime || $arg instanceof \DateTimeInterface)) {
|
||||
return sprintf("[object] (%s)", get_class($arg));
|
||||
return sprintf("[object] (%s)", Registry::getClass($arg));
|
||||
}
|
||||
|
||||
return $arg;
|
||||
|
Reference in New Issue
Block a user