Example #1
0
 protected function resolveLoggerConfig()
 {
     $candidate = null;
     foreach ($this->config->loggers as $nodeName => $config) {
         if ($candidate === null && $nodeName === self::ROOT_LOGGER || self::isMoreSpecific($candidate, $nodeName, $this->loggerName)) {
             $candidate = $nodeName;
         }
     }
     //store the config logger name
     $this->actualLoggerName = $candidate;
     $loggerConfig = $this->config->loggers->{$candidate};
     //set the bubbling configuration
     if (!is_null($loggerConfig->bubbleUp)) {
         $this->bubbleUp = $loggerConfig->bubbleUp;
     }
     $writers = $loggerConfig->writers;
     if ($writers) {
         foreach ($writers as $writer) {
             if ($writer->writer === null) {
                 throw new LoggerException(sprintf("Incorrect logger definition."));
             }
             $writerConfig = $this->config->writers->{$writer->writer};
             if ($writerConfig === null) {
                 throw new LoggerException(sprintf("Could not locate a writer definition named: %s", $writer->writer));
             }
             $this->filters[$writer->writer] = new Filter($this, Level::fromString($writer->level), Writer::runFactory($writer->writer, $writerConfig));
         }
     } else {
         throw new LoggerException(sprintf("No writers defined for logger: %s", $this->loggerName));
     }
 }
Example #2
0
 /**
  * 
  * @param String $msg
  * @param array $context
  */
 protected static function extendContext($msg, array $context)
 {
     $context[self::MESSAGE] = $msg;
     $context[self::NEW_LINE] = "\n";
     $context[self::DATE] = date('c');
     $context[self::PID] = self::getPid();
     $context[self::PERCENT] = '%';
     if (array_key_exists(self::LOG_LEVEL, $context)) {
         $context[self::LOG_LEVEL] = Level::toString($context[self::LOG_LEVEL]);
     }
     return $context;
 }