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']);
         }
     }
 }
Esempio n. 2
0
 public function testAddictive()
 {
     $rootAppender = new AppenderTest();
     $root = new Logger('root');
     $root->addAppender($rootAppender);
     $logger = new Logger('logger', $root);
     $this->assertTrue($logger->getAddictive());
     $this->assertSame($root, $logger->getParent());
     $logger->log(1, 'test1', $exFirst = new \Exception());
     $this->assertSame([[1, 'test1']], $rootAppender->logs);
     $logger->setAddictive(false);
     $this->assertFalse($logger->getAddictive());
     $logger->log(2, 'test2', $exSecond = new \Exception());
     $this->assertSame([[1, 'test1']], $rootAppender->logs);
 }