Skip to content

Commit 841ecbe

Browse files
committed
Merge pull request #634 from henriquemoody/resource_type
Better normalization for resources
2 parents d4af968 + 50fb249 commit 841ecbe

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Monolog/Formatter/NormalizerFormatter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function normalize($data)
106106
}
107107

108108
if (is_resource($data)) {
109-
return '[resource]';
109+
return sprintf('[resource] (%s)', get_resource_type($data));
110110
}
111111

112112
return '[unknown('.gettype($data).')]';

tests/Monolog/Formatter/LineFormatterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function testDefFormatWithObject()
103103
'message' => 'foobar',
104104
));
105105

106-
$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);
106+
$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);
107107
}
108108

109109
public function testDefFormatWithException()

tests/Monolog/Formatter/NormalizerFormatterTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testFormat()
4343
'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})',
4444
'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: bar)',
4545
'baz' => array(),
46-
'res' => '[resource]',
46+
'res' => '[resource] (stream)',
4747
),
4848
'context' => array(
4949
'foo' => 'bar',
@@ -219,7 +219,7 @@ public function testExceptionTraceWithArgs()
219219
$result = $formatter->format($record);
220220

221221
$this->assertRegExp(
222-
'%"resource":"\[resource\]"%',
222+
'%"resource":"\[resource\] \(stream\)"%',
223223
$result['context']['exception']['trace'][0]
224224
);
225225

0 commit comments

Comments
 (0)