24 $logger =
new Logger(
'foo');
25 $this->assertEquals(
'foo', $logger->getName());
33 $this->assertEquals(
'ERROR', Logger::getLevelName(Logger::ERROR));
42 $second = $first->withName(
'second');
44 $this->assertSame(
'first', $first->getName());
45 $this->assertSame(
'second', $second->getName());
46 $this->assertSame($handler, $second->popHandler());
54 $this->assertEquals(Logger::toMonologLevel(
'debug'), 100);
55 $this->assertEquals(Logger::toMonologLevel(
'info'), 200);
56 $this->assertEquals(Logger::toMonologLevel(
'notice'), 250);
57 $this->assertEquals(Logger::toMonologLevel(
'warning'), 300);
58 $this->assertEquals(Logger::toMonologLevel(
'error'), 400);
59 $this->assertEquals(Logger::toMonologLevel(
'critical'), 500);
60 $this->assertEquals(Logger::toMonologLevel(
'alert'), 550);
61 $this->assertEquals(Logger::toMonologLevel(
'emergency'), 600);
70 Logger::getLevelName(5);
78 $logger =
new Logger(
'foo');
80 $logger->pushHandler($handler);
81 $logger->addWarning(
'test');
83 $this->assertEquals(
'foo', $record[
'channel']);
91 $logger =
new Logger(__METHOD__);
93 $handler = $this->getMock(
'Monolog\Handler\NullHandler',
array(
'handle'));
94 $handler->expects($this->once())
96 $logger->pushHandler($handler);
98 $this->assertTrue($logger->addWarning(
'test'));
106 $logger =
new Logger(__METHOD__);
108 $handler = $this->getMock(
'Monolog\Handler\NullHandler',
array(
'handle'),
array(Logger::ERROR));
109 $handler->expects($this->never())
111 $logger->pushHandler($handler);
113 $this->assertFalse($logger->addWarning(
'test'));
120 $logger =
new Logger(__METHOD__,
array($handler1, $handler2));
122 $this->assertEquals($handler1, $logger->popHandler());
123 $this->assertEquals($handler2, $logger->popHandler());
132 $this->assertEquals($processor1, $logger->popProcessor());
133 $this->assertEquals($processor2, $logger->popProcessor());
143 $logger =
new Logger(__METHOD__);
147 $logger->pushHandler($handler1);
148 $logger->pushHandler($handler2);
150 $this->assertEquals($handler2, $logger->popHandler());
151 $this->assertEquals($handler1, $logger->popHandler());
152 $logger->popHandler();
160 $logger =
new Logger(__METHOD__);
164 $logger->pushHandler($handler1);
165 $logger->setHandlers(
array($handler2));
168 $this->assertEquals(
array($handler2), $logger->getHandlers());
170 $logger->setHandlers(
array(
171 "AMapKey" => $handler1,
176 $this->assertEquals(
array($handler1, $handler2), $logger->getHandlers());
186 $logger =
new Logger(__METHOD__);
190 $logger->pushProcessor($processor1);
191 $logger->pushProcessor($processor2);
193 $this->assertEquals($processor2, $logger->popProcessor());
194 $this->assertEquals($processor1, $logger->popProcessor());
195 $logger->popProcessor();
204 $logger =
new Logger(__METHOD__);
206 $logger->pushProcessor(
new \stdClass());
214 $logger =
new Logger(__METHOD__);
216 $logger->pushHandler($handler);
218 $record[
'extra'][
'win'] =
true;
222 $logger->addError(
'test');
223 list($record) = $handler->getRecords();
224 $this->assertTrue($record[
'extra'][
'win']);
232 $logger =
new Logger(__METHOD__);
233 $handler = $this->getMock(
'Monolog\Handler\HandlerInterface');
234 $handler->expects($this->any())
235 ->method(
'isHandling')
236 ->will($this->returnValue(
true))
238 $handler->expects($this->any())
240 ->will($this->returnValue(
true))
242 $logger->pushHandler($handler);
244 $processor = $this->getMockBuilder(
'Monolog\Processor\WebProcessor')
245 ->disableOriginalConstructor()
246 ->setMethods(
array(
'__invoke'))
249 $processor->expects($this->once())
251 ->will($this->returnArgument(0))
253 $logger->pushProcessor($processor);
255 $logger->addError(
'test');
263 $logger =
new Logger(__METHOD__);
264 $handler = $this->getMock(
'Monolog\Handler\HandlerInterface');
265 $handler->expects($this->once())
266 ->method(
'isHandling')
267 ->will($this->returnValue(
false))
269 $logger->pushHandler($handler);
271 $logger->pushProcessor(
function ($record) use ($that) {
272 $that->fail(
'The processor should not be called');
274 $logger->addAlert(
'test');
282 $logger =
new Logger(__METHOD__);
284 $handler1 = $this->getMock(
'Monolog\Handler\HandlerInterface');
285 $handler1->expects($this->never())
286 ->method(
'isHandling')
287 ->will($this->returnValue(
false))
289 $handler1->expects($this->once())
291 ->will($this->returnValue(
false))
293 $logger->pushHandler($handler1);
295 $handler2 = $this->getMock(
'Monolog\Handler\HandlerInterface');
296 $handler2->expects($this->once())
297 ->method(
'isHandling')
298 ->will($this->returnValue(
true))
300 $handler2->expects($this->once())
302 ->will($this->returnValue(
false))
304 $logger->pushHandler($handler2);
306 $handler3 = $this->getMock(
'Monolog\Handler\HandlerInterface');
307 $handler3->expects($this->once())
308 ->method(
'isHandling')
309 ->will($this->returnValue(
false))
311 $handler3->expects($this->never())
314 $logger->pushHandler($handler3);
316 $logger->debug(
'test');
324 $handler1 = $this->getMock(
'Monolog\Handler\HandlerInterface');
325 $handler1->expects($this->never())
326 ->method(
'isHandling')
327 ->will($this->returnValue(
false))
329 $handler1->expects($this->once())
331 ->will($this->returnValue(
false))
334 $handler2 = $this->getMock(
'Monolog\Handler\HandlerInterface');
335 $handler2->expects($this->once())
336 ->method(
'isHandling')
337 ->will($this->returnValue(
true))
339 $handler2->expects($this->once())
341 ->will($this->returnValue(
false))
344 $handler3 = $this->getMock(
'Monolog\Handler\HandlerInterface');
345 $handler3->expects($this->once())
346 ->method(
'isHandling')
347 ->will($this->returnValue(
false))
349 $handler3->expects($this->never())
353 $logger =
new Logger(__METHOD__,
array(
'last' => $handler3,
'second' => $handler2,
'first' => $handler1));
355 $logger->debug(
'test');
363 $logger =
new Logger(__METHOD__);
365 $handler1 = $this->getMock(
'Monolog\Handler\HandlerInterface');
366 $handler1->expects($this->any())
367 ->method(
'isHandling')
368 ->will($this->returnValue(
true))
370 $handler1->expects($this->once())
372 ->will($this->returnValue(
false))
374 $logger->pushHandler($handler1);
376 $handler2 = $this->getMock(
'Monolog\Handler\HandlerInterface');
377 $handler2->expects($this->any())
378 ->method(
'isHandling')
379 ->will($this->returnValue(
true))
381 $handler2->expects($this->once())
383 ->will($this->returnValue(
false))
385 $logger->pushHandler($handler2);
387 $logger->debug(
'test');
395 $logger =
new Logger(__METHOD__);
397 $handler1 = $this->getMock(
'Monolog\Handler\HandlerInterface');
398 $handler1->expects($this->any())
399 ->method(
'isHandling')
400 ->will($this->returnValue(
true))
402 $handler1->expects($this->never())
405 $logger->pushHandler($handler1);
407 $handler2 = $this->getMock(
'Monolog\Handler\HandlerInterface');
408 $handler2->expects($this->any())
409 ->method(
'isHandling')
410 ->will($this->returnValue(
true))
412 $handler2->expects($this->once())
414 ->will($this->returnValue(
true))
416 $logger->pushHandler($handler2);
418 $logger->debug(
'test');
426 $logger =
new Logger(__METHOD__);
428 $handler1 = $this->getMock(
'Monolog\Handler\HandlerInterface');
429 $handler1->expects($this->any())
430 ->method(
'isHandling')
431 ->will($this->returnValue(
false))
434 $logger->pushHandler($handler1);
437 $handler2 = $this->getMock(
'Monolog\Handler\HandlerInterface');
438 $handler2->expects($this->any())
439 ->method(
'isHandling')
440 ->will($this->returnValue(
true))
443 $logger->pushHandler($handler2);
468 $logger =
new Logger(
'foo');
470 $logger->pushHandler($handler);
471 $logger->{$method}(
'test');
473 $this->assertEquals($expectedLevel, $record[
'level']);
481 array(
'addInfo', Logger::INFO),
482 array(
'addNotice', Logger::NOTICE),
483 array(
'addWarning', Logger::WARNING),
484 array(
'addError', Logger::ERROR),
485 array(
'addCritical', Logger::CRITICAL),
486 array(
'addAlert', Logger::ALERT),
487 array(
'addEmergency', Logger::EMERGENCY),
491 array(
'info', Logger::INFO),
492 array(
'notice', Logger::NOTICE),
493 array(
'warn', Logger::WARNING),
494 array(
'err', Logger::ERROR),
495 array(
'crit', Logger::CRITICAL),
496 array(
'alert', Logger::ALERT),
497 array(
'emerg', Logger::EMERGENCY),
507 Logger::setTimezone(
$tz);
508 $logger =
new Logger(
'foo');
510 $logger->pushHandler($handler);
511 $logger->info(
'test');
513 $this->assertEquals(
$tz, $record[
'datetime']->getTimezone());
519 function (
$tz) {
return array(
new \DateTimeZone(
$tz)); },
520 \DateTimeZone::listIdentifiers()
531 $logger =
new Logger(
'foo');
532 $logger->useMicrosecondTimestamps($micro);
534 $logger->pushHandler($handler);
535 $logger->info(
'test');
537 $this->{$assert}(
'000000', $record[
'datetime']->format(
'u'));
544 'with microseconds' =>
array(
true,
'assertNotSame'),
545 'without microseconds' =>
array(
false,
'assertSame'),
testLogNotHandled()
Monolog::addRecord
testProcessorsAreExecuted()
Monolog::addRecord
testSetHandlers()
Monolog::setHandlers
Injects url/method and remote IP of the current web request in all records.
testBubblingWhenTheHandlerReturnsFalse()
Monolog::addRecord
testConvertPSR3ToMonologLevel()
Monolog::toMonologLevel
testIsHandling()
Monolog::isHandling
testChannel()
Monolog::__construct
testSetTimezone($tz)
setTimezoneProvider Monolog::setTimezone
testGetName()
Monolog::getName
testLog()
Monolog::addRecord
testProcessorsNotCalledWhenNotHandled()
Monolog::addRecord
testHandlersNotCalledBeforeFirstHandlingWithAssocArray()
Monolog::addRecord
Create styles array
The data for the language used.
testGetLevelNameThrows()
Monolog::getLevelName InvalidArgumentException
testHandlersNotCalledBeforeFirstHandling()
Monolog::addRecord
testProcessorsAreCalledOnlyOnce()
Monolog::addRecord
testPushProcessorWithNonCallable()
Monolog::pushProcessor InvalidArgumentException
testLogMethods($method, $expectedLevel)
logMethodProvider Monolog::addDebug Monolog::addInfo Monolog::addNotice Monolog::addWarning Mono...
testWithName()
Monolog::withName
Used for testing purposes.
useMicrosecondTimestampsProvider()
testUseMicrosecondTimestamps($micro, $assert)
useMicrosecondTimestampsProvider Monolog::useMicrosecondTimestamps Monolog::addRecord ...
testPushPopHandler()
Monolog::pushHandler Monolog::popHandler LogicException
testGetLevelName()
Monolog::getLevelName
testNotBubblingWhenTheHandlerReturnsTrue()
Monolog::addRecord
pushProcessor($callback)
{Adds a processor in the stack.self}
testPushPopProcessor()
Monolog::pushProcessor Monolog::popProcessor LogicException