예제 #1
0
 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));
 }