mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-14 09:04:15 +02:00
Add support for serializing resources in LineFormatter
This commit is contained in:
@@ -96,6 +96,10 @@ class LineFormatter implements FormatterInterface
|
|||||||
return $normalized;
|
return $normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_resource($data)) {
|
||||||
|
return '[resource]';
|
||||||
|
}
|
||||||
|
|
||||||
return sprintf("[object] (%s: %s)", get_class($data), json_encode($data));
|
return sprintf("[object] (%s: %s)", get_class($data), json_encode($data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -68,10 +68,10 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
'channel' => 'meh',
|
'channel' => 'meh',
|
||||||
'context' => array(),
|
'context' => array(),
|
||||||
'datetime' => new \DateTime,
|
'datetime' => new \DateTime,
|
||||||
'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array()),
|
'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')),
|
||||||
'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: {})","baz":[]}'."\n", $message);
|
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\Formatter\\TestFoo: {"foo":"foo"})","bar":"[object] (Monolog\\Formatter\\TestBar: {})","baz":[],"res":"[resource]"}'."\n", $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBatchFormat()
|
public function testBatchFormat()
|
||||||
|
Reference in New Issue
Block a user