mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-09 14:46:46 +02:00
Merge branch '2.x'
This commit is contained in:
@@ -162,7 +162,7 @@ class LineFormatter extends NormalizerFormatter
|
||||
do {
|
||||
$depth++;
|
||||
if ($depth > $this->maxNormalizeDepth) {
|
||||
$str .= '\n[previous exception] Over ' . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
|
||||
$str .= "\n[previous exception] Over " . $this->maxNormalizeDepth . ' levels deep, aborting normalization';
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -206,6 +206,9 @@ class NormalizerFormatter implements FormatterInterface
|
||||
if ($data instanceof \JsonSerializable) {
|
||||
/** @var null|scalar|array<mixed[]|scalar|null> $value */
|
||||
$value = $data->jsonSerialize();
|
||||
} elseif (\get_class($data) === '__PHP_Incomplete_Class') {
|
||||
$accessor = new \ArrayObject($data);
|
||||
$value = (string) $accessor['__PHP_Incomplete_Class_Name'];
|
||||
} elseif (method_exists($data, '__toString')) {
|
||||
/** @var string $value */
|
||||
$value = $data->__toString();
|
||||
|
@@ -123,11 +123,14 @@ class StreamHandler extends AbstractProcessingHandler
|
||||
$this->createDir($url);
|
||||
$this->errorMessage = null;
|
||||
set_error_handler([$this, 'customErrorHandler']);
|
||||
try {
|
||||
$stream = fopen($url, 'a');
|
||||
if ($this->filePermission !== null) {
|
||||
@chmod($url, $this->filePermission);
|
||||
}
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
if (!is_resource($stream)) {
|
||||
$this->stream = null;
|
||||
|
||||
|
@@ -402,6 +402,20 @@ class NormalizerFormatterTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanNormalizeIncompleteObject(): void
|
||||
{
|
||||
$serialized = "O:17:\"Monolog\TestClass\":1:{s:23:\"\x00Monolog\TestClass\x00name\";s:4:\"test\";}";
|
||||
$object = unserialize($serialized);
|
||||
|
||||
$formatter = new NormalizerFormatter();
|
||||
$record = $this->getRecord(context: ['object' => $object]);
|
||||
$result = $formatter->format($record);
|
||||
|
||||
$this->assertEquals([
|
||||
'__PHP_Incomplete_Class' => 'Monolog\\TestClass',
|
||||
], $result['context']['object']);
|
||||
}
|
||||
|
||||
private function throwHelper($arg)
|
||||
{
|
||||
throw new \RuntimeException('Thrown');
|
||||
|
Reference in New Issue
Block a user