1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-02-21 13:33:52 +01:00

Better normalization for resources

This commit is contained in:
Henrique Moody 2015-08-20 15:00:04 -03:00
parent d58755629d
commit 50fb249739
3 changed files with 4 additions and 4 deletions

View File

@ -106,7 +106,7 @@ class NormalizerFormatter implements FormatterInterface
}
if (is_resource($data)) {
return '[resource]';
return sprintf('[resource] (%s)', get_resource_type($data));
}
return '[unknown('.gettype($data).')]';

View File

@ -103,7 +103,7 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
'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()

View File

@ -43,7 +43,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})',
'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: bar)',
'baz' => array(),
'res' => '[resource]',
'res' => '[resource] (stream)',
),
'context' => array(
'foo' => 'bar',
@ -219,7 +219,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
$result = $formatter->format($record);
$this->assertRegExp(
'%"resource":"\[resource\]"%',
'%"resource":"\[resource\] \(stream\)"%',
$result['context']['exception']['trace'][0]
);