23 if (!class_exists(
'MongoDate')) {
24 $this->markTestSkipped(
'mongo extension not installed');
31 array(1,
true, 1,
true),
32 array(0,
false, 0,
false),
44 public function testConstruct($traceDepth, $traceAsString, $expectedTraceDepth, $expectedTraceAsString)
48 $reflTrace = new \ReflectionProperty($formatter,
'exceptionTraceAsString');
49 $reflTrace->setAccessible(
true);
50 $this->assertEquals($expectedTraceAsString, $reflTrace->getValue($formatter));
52 $reflDepth = new\ReflectionProperty($formatter,
'maxNestingLevel');
53 $reflDepth->setAccessible(
true);
54 $this->assertEquals($expectedTraceDepth, $reflDepth->getValue($formatter));
60 'message' =>
'some log message',
65 'datetime' =>
new \
DateTime(
'2014-02-01 00:00:00'),
70 $formattedRecord = $formatter->format($record);
72 $this->assertCount(7, $formattedRecord);
73 $this->assertEquals(
'some log message', $formattedRecord[
'message']);
74 $this->assertEquals(
array(), $formattedRecord[
'context']);
77 $this->assertEquals(
'test', $formattedRecord[
'channel']);
78 $this->assertInstanceOf(
'\MongoDate', $formattedRecord[
'datetime']);
79 $this->assertEquals(
'0.00000000 1391212800', $formattedRecord[
'datetime']->__toString());
80 $this->assertEquals(
array(), $formattedRecord[
'extra']);
85 $someObject = new \stdClass();
86 $someObject->foo =
'something';
87 $someObject->bar =
'stuff';
90 'message' =>
'some log message',
92 'stuff' =>
new \
DateTime(
'2014-02-01 02:31:33'),
93 'some_object' => $someObject,
94 'context_string' =>
'some string',
95 'context_int' => 123456,
96 'except' =>
new \
Exception(
'exception message', 987),
101 'datetime' =>
new \
DateTime(
'2014-02-01 00:00:00'),
106 $formattedRecord = $formatter->format($record);
108 $this->assertCount(5, $formattedRecord[
'context']);
109 $this->assertInstanceOf(
'\MongoDate', $formattedRecord[
'context'][
'stuff']);
110 $this->assertEquals(
'0.00000000 1391221893', $formattedRecord[
'context'][
'stuff']->__toString());
113 'foo' =>
'something',
115 'class' =>
'stdClass',
117 $formattedRecord[
'context'][
'some_object']
119 $this->assertEquals(
'some string', $formattedRecord[
'context'][
'context_string']);
120 $this->assertEquals(123456, $formattedRecord[
'context'][
'context_int']);
122 $this->assertCount(5, $formattedRecord[
'context'][
'except']);
123 $this->assertEquals(
'exception message', $formattedRecord[
'context'][
'except'][
'message']);
124 $this->assertEquals(987, $formattedRecord[
'context'][
'except'][
'code']);
125 $this->assertInternalType(
'string', $formattedRecord[
'context'][
'except'][
'file']);
126 $this->assertInternalType(
'integer', $formattedRecord[
'context'][
'except'][
'code']);
127 $this->assertInternalType(
'string', $formattedRecord[
'context'][
'except'][
'trace']);
128 $this->assertEquals(
'Exception', $formattedRecord[
'context'][
'except'][
'class']);
134 'message' =>
'some log message',
137 'property' =>
'anything',
140 'property' =>
'nothing',
147 'datetime' =>
new \
DateTime(
'2014-02-01 00:00:00'),
152 $formattedResult = $formatter->format($record);
157 'property' =>
'anything',
161 $formattedResult[
'context']
168 'message' =>
'some log message',
171 'property' =>
'something',
173 'property' =>
'anything',
175 'property' =>
'nothing',
183 'datetime' =>
new \
DateTime(
'2014-02-01 00:00:00'),
188 $formattedResult = $formatter->format($record);
193 'property' =>
'something',
195 'property' =>
'anything',
197 'property' =>
'nothing',
202 $formattedResult[
'context']
208 $someObject = new \stdClass();
209 $someObject->property =
'anything';
210 $someObject->nest3 = new \stdClass();
211 $someObject->nest3->property =
'nothing';
212 $someObject->nest3->nest4 =
'invisible';
215 'message' =>
'some log message',
217 'nest2' => $someObject,
222 'datetime' =>
new \
DateTime(
'2014-02-01 00:00:00'),
227 $formattedResult = $formatter->format($record);
232 'property' =>
'anything',
234 'class' =>
'stdClass',
237 $formattedResult[
'context']
244 'message' =>
'some log message',
246 'nest2' =>
new \
Exception(
'exception message', 987),
251 'datetime' =>
new \
DateTime(
'2014-02-01 00:00:00'),
256 $formattedRecord = $formatter->format($record);
258 $this->assertEquals(
'exception message', $formattedRecord[
'context'][
'nest2'][
'message']);
259 $this->assertEquals(987, $formattedRecord[
'context'][
'nest2'][
'code']);
260 $this->assertEquals(
'[...]', $formattedRecord[
'context'][
'nest2'][
'trace']);
const WARNING
Exceptional occurrences that are not errors.
Create styles array
The data for the language used.
static getLevelName($level)
Gets the name of the logging level.