Esempio n. 1
0
 /**
  * The generic log method. First verifies the log level's validity and then
  * interpolates and formats the message and outputs it (on the screen, in
  * a file, depending on the output implementation provided etc)
  * 
  * @param string $level the log level
  * @param string $message the message
  * @param array $context the message's context/placeholders
  * @return null
  * 
  * @see \Dialog\Log\LoggerInterface::log()
  */
 public function log($level, $message, array $context = [])
 {
     // Check if level is allowed, or throw an InvalidArgumentException
     $this->isLevelAllowed($level);
     // interpolate the message
     $message = $this->interpolator->interpolate($message, $context);
     // format and add DateTimes etc
     $message = $this->formatter->format($level, $message);
     // output to the appropriate place
     $this->output->output($message);
 }
Esempio n. 2
0
 /**
  * The generic log method. First verifies the log level's validity and then
  * interpolates and formats the message and processes it (passes it to all
  * of the registered handlers for the logger)
  *
  * @param string $level the log level
  * @param string $message the message
  * @param array $context the message's context/placeholders
  * @return null
  *
  * @see \Dialog\Log\LoggerInterface::log()
  */
 public function log($level, $message, array $context = [])
 {
     // Check if level is allowed, or throw an InvalidArgumentException
     if (!$this->isLevelAllowed($level)) {
         throw new InvalidArgumentException('Invalid log level provided');
     }
     // interpolate the message
     $message = $this->interpolator->interpolate($message, $context);
     foreach ($this->handlerBag->handlers() as $handler) {
         $handler->handle($level, $message);
     }
 }