예제 #1
0
 private function createLogger(Logger $logger, LoggerHierarchy $hierarchy, array $config)
 {
     if (isset($config['appenders'])) {
         foreach ($config['appenders'] as $appenderConfig) {
             if (is_string($appenderConfig)) {
                 $appender = $hierarchy->getAppender($appenderConfig);
             } elseif (is_array($appenderConfig)) {
                 $appender = $this->createAppender($hierarchy, $appenderConfig);
             } else {
                 LoggerPolicy::processConfigurationError('Appender invalid config');
                 continue;
             }
             $logger->addAppender($appender);
         }
         if (isset($config['addictive'])) {
             $logger->setAddictive($config['addictive']);
         }
         if (isset($config['maxLevel'])) {
             $logger->setMaxLevel($config['maxLevel']);
         }
         if (isset($config['minLevel'])) {
             $logger->setMinLevel($config['minLevel']);
         }
     }
 }
예제 #2
0
 public function testMinLevel()
 {
     $logger = new Logger('root');
     $appender = new AppenderTest();
     $logger->addAppender($appender);
     $logger->log(Logger::INFO, 1);
     $this->assertSame([[Logger::INFO, 1]], $appender->logs);
     $logger->setMinLevel(Logger::INFO);
     $logger->log(Logger::INFO, 2);
     $logger->log(Logger::DEBUG, 3);
     $this->assertSame([[Logger::INFO, 1], [Logger::INFO, 2]], $appender->logs);
 }