mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-04 20:27:31 +02:00
Better normalization for resources
This commit is contained in:
@@ -106,7 +106,7 @@ class NormalizerFormatter implements FormatterInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_resource($data)) {
|
if (is_resource($data)) {
|
||||||
return '[resource]';
|
return sprintf('[resource] (%s)', get_resource_type($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
return '[unknown('.gettype($data).')]';
|
return '[unknown('.gettype($data).')]';
|
||||||
|
@@ -103,7 +103,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
'message' => 'foobar',
|
'message' => 'foobar',
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: bar)","baz":[],"res":"[resource]"}'."\n", $message);
|
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: bar)","baz":[],"res":"[resource] (stream)"}'."\n", $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDefFormatWithException()
|
public function testDefFormatWithException()
|
||||||
|
@@ -43,7 +43,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})',
|
'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})',
|
||||||
'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: bar)',
|
'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: bar)',
|
||||||
'baz' => array(),
|
'baz' => array(),
|
||||||
'res' => '[resource]',
|
'res' => '[resource] (stream)',
|
||||||
),
|
),
|
||||||
'context' => array(
|
'context' => array(
|
||||||
'foo' => 'bar',
|
'foo' => 'bar',
|
||||||
@@ -219,7 +219,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
$result = $formatter->format($record);
|
$result = $formatter->format($record);
|
||||||
|
|
||||||
$this->assertRegExp(
|
$this->assertRegExp(
|
||||||
'%"resource":"\[resource\]"%',
|
'%"resource":"\[resource\] \(stream\)"%',
|
||||||
$result['context']['exception']['trace'][0]
|
$result['context']['exception']['trace'][0]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user