Exemplo n.º 1
0
 /**
  * Tests multiple loggers
  *
  * @issue  2798
  * @author Serghei Iakovlev <*****@*****.**>
  * @since  2016-01-28
  */
 public function testMultipleLoggers()
 {
     $this->specify("Multiple logging does not works correctly", function () {
         $I = $this->tester;
         $file1 = $I->getNewFileName('log', 'log');
         $file2 = $I->getNewFileName('log', 'log');
         $logger = new Multiple();
         $logger->push(new File($this->logPath . $file1));
         $logger->push(new File($this->logPath . $file2));
         $logger->setFormatter(new Json());
         $logger->log('This is a message');
         $logger->log("This is an error", Logger::ERROR);
         $logger->error("This is another error");
         $expected = sprintf('{"type":"DEBUG","message":"This is a message","timestamp":%s}' . PHP_EOL . '{"type":"ERROR","message":"This is an error","timestamp":%s}' . PHP_EOL . '{"type":"ERROR","message":"This is another error","timestamp":%s}' . PHP_EOL, time(), time(), time());
         $I->amInPath($this->logPath);
         $I->openFile($file1);
         $I->seeFileContentsEqual($expected);
         $I->deleteFile($file1);
         $I->openFile($file2);
         $I->seeFileContentsEqual($expected);
         $I->deleteFile($file2);
     });
 }
Exemplo n.º 2
0
 public function setFormatter(FormatterInterface $formatter)
 {
     parent::setFormatter($formatter);
 }