Ejemplo n.º 1
0
 public function testPassingProperLevelsToWriters()
 {
     foreach (array('emergency' => LogLevel::EMERGENCY, 'alert' => LogLevel::ALERT, 'critical' => LogLevel::CRITICAL, 'error' => LogLevel::ERROR, 'warning' => LogLevel::WARNING, 'notice' => LogLevel::NOTICE, 'info' => LogLevel::INFO, 'debug' => LogLevel::DEBUG) as $method => $level) {
         $logger = new Logger('text', '123');
         $message = 'Calling log "' . $method . '" at level ' . $level;
         $writer = $this->getMock('Psr\\Log\\LoggerInterface');
         $writer->expects($this->atLeastOnce())->method('log')->with($level, $message, $this->anything());
         $logger->addWriter($writer);
         call_user_func_array(array($logger, $method), array($message));
     }
 }
Ejemplo n.º 2
0
 /**
  * Provides a logger with the given name.
  *
  * @param  string $name Name of the logger to be provided.
  * @return LoggerInterface
  */
 public function provideLogger($name)
 {
     if (isset($this->loggers[$name])) {
         return $this->loggers[$name];
     }
     $logger = new Logger($name, $this->uuid);
     // also add all writers
     foreach ($this->writers as $writer) {
         $logger->addWriter($writer);
     }
     $this->loggers[$name] = $logger;
     return $logger;
 }