示例#1
0
 public function testRenderNullAndBool()
 {
     LoggerRender::$nullMessage = '-';
     LoggerRender::$trueMessage = '1';
     LoggerRender::$falseMessage = '-1';
     $logger = new Logger('testLogger');
     $layout = new LayoutSimple();
     $this->assertSame('testLogger [INFO] - -' . PHP_EOL, $layout->formatMessage($logger, Logger::INFO, null));
     $this->assertSame('testLogger [INFO] - 1' . PHP_EOL, $layout->formatMessage($logger, Logger::INFO, true));
     $this->assertSame('testLogger [INFO] - -1' . PHP_EOL, $layout->formatMessage($logger, Logger::INFO, false));
 }
 public function configure(LoggerHierarchy $hierarchy, array $config)
 {
     if (isset($config[static::LOGGER_POLICY]['ioError'])) {
         LoggerPolicy::setIoErrorPolicy($config[static::LOGGER_POLICY]['ioError']);
     }
     if (isset($config[static::LOGGER_POLICY]['configurationError'])) {
         LoggerPolicy::setConfigurationErrorPolicy($config[static::LOGGER_POLICY]['configurationError']);
     }
     if (isset($config[static::LOGGER_RENDERER])) {
         if (isset($config[static::LOGGER_RENDERER]['nullMessage'])) {
             LoggerRender::$nullMessage = (string) $config[static::LOGGER_RENDERER]['nullMessage'];
         }
         if (isset($config[static::LOGGER_RENDERER]['trueMessage'])) {
             LoggerRender::$trueMessage = (string) $config[static::LOGGER_RENDERER]['trueMessage'];
         }
         if (isset($config[static::LOGGER_RENDERER]['falseMessage'])) {
             LoggerRender::$falseMessage = (string) $config[static::LOGGER_RENDERER]['falseMessage'];
         }
     }
     if (isset($config[static::LOGGER_LAYOUTS])) {
         foreach ($config[static::LOGGER_LAYOUTS] as $layoutName => $layoutConfig) {
             $hierarchy->setLayout($layoutName, $this->createLayout($layoutConfig));
         }
     }
     if (isset($config[static::LOGGER_APPENDERS])) {
         foreach ($config[static::LOGGER_APPENDERS] as $appenderName => $appenderConfig) {
             $hierarchy->setAppender($appenderName, $this->createAppender($hierarchy, $appenderConfig));
         }
     }
     if (isset($config[static::LOGGER_LOGGERS])) {
         foreach ($config[static::LOGGER_LOGGERS] as $loggerName => $loggerConfig) {
             $logger = $hierarchy->getLogger($loggerName);
             $this->createLogger($logger, $hierarchy, $loggerConfig);
         }
     }
     if (isset($config[static::LOGGER_ROOT])) {
         $logger = $hierarchy->getRootLogger();
         $this->createLogger($logger, $hierarchy, $config[static::LOGGER_ROOT]);
     }
 }