public function testTest() { Logger::configure(['appenders' => ['stream' => ['class' => AppenderStream::class, 'stream' => '/dev/null']], 'root' => ['appenders' => ['stream']]]); $logger = Logger::getLogger('test'); $start = microtime(1); for ($i = 1000; --$i;) { $logger->info('test'); } $end = microtime(1); $this->assertLessThan(1.0, $end - $start, 'logger > root > stream'); $logger = Logger::getRootLogger(); $start = microtime(1); for ($i = 1000; --$i;) { $logger->info('test'); } $end = microtime(1); $this->assertLessThan(1.0, $end - $start, 'root > stream'); $appenders = Logger::getRootLogger()->getAppenders(); $appender = $appenders[0]; $start = microtime(1); for ($i = 1000; --$i;) { $appender->append($logger, Logger::INFO, 'test', null); } $end = microtime(1); $this->assertLessThan(1.0, $end - $start, 'stream'); }
public function testLogStream() { $path = '/tmp/log.txt'; if (is_file($path)) { unlink($path); } Logger::configure(); $appender = new AppenderStream($path); $appender->setLayout(new LayoutSimple()); Logger::getRootLogger()->addAppender($appender); Logger::getRootLogger()->info('hello world'); $this->assertSame('root [INFO] - hello world' . PHP_EOL, file_get_contents($path)); }
} /* @noinspection PhpIncludeInspection */ $config = (require $params['config']); if (!$config) { echo "Config should be not empty\n"; exit(1); } if (!is_array($config)) { echo "Config should be array\n"; exit(1); } $loggerConfig = []; if (isset($config['loggerConfig']) && is_array($config['loggerConfig'])) { $loggerConfig = $config['loggerConfig']; } Logger::configure($loggerConfig); $processor = new Processor(); $signalHandler = new SignalHandler(); $processor->setSignalHandler($signalHandler); if (!isset($config['mainConfig'])) { echo "You should specify mainConfig key in config. See documentation for more information.\n"; exit(1); } $processor->setMainConfig($config['mainConfig']); if (!isset($config['processorConfig'])) { echo "You should specify processorConfig key in config. See documentation.\n"; exit(1); } if (!isset($config['processorConfig']['configReader'])) { echo "You should specify processorConfig.configReader key in config. See documentation.\n"; exit(1);