public function addDebugLogger(Logger $logger, SymfonyStyle $output)
 {
     $lineFormatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message%\n");
     $lineFormatter->allowInlineLineBreaks(true);
     $lineFormatter->ignoreEmptyContextAndExtra(true);
     $stdoutHandler = new PsrHandler(new ConsoleLogger($output));
     $stdoutHandler->setFormatter($lineFormatter);
     $logger->pushHandler($stdoutHandler);
 }
Пример #2
0
 /**
  * @dataProvider logLevelProvider
  */
 public function testHandlesAllLevels($levelName, $level)
 {
     $message = 'Hello, world! ' . $level;
     $context = array('foo' => 'bar', 'level' => $level);
     $psrLogger = $this->getMock('Psr\\Log\\NullLogger');
     $psrLogger->expects($this->once())->method('log')->with(strtolower($levelName), $message, $context);
     $handler = new PsrHandler($psrLogger);
     $handler->handle(array('level' => $level, 'level_name' => $levelName, 'message' => $message, 'context' => $context));
 }