Phalcon\Test\Unit\Logger\Adapter\FileTest::testMultipleLoggers PHP Method

testMultipleLoggers() public method

Tests multiple loggers
Since: 2016-01-28
Author: Serghei Iakovlev ([email protected])
public testMultipleLoggers ( )
    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());
            $expected = '{"type":"DEBUG","message":"This is a message","timestamp":' . time() . '}' . PHP_EOL;
            $logger->log('This is a message');
            $expected .= '{"type":"ERROR","message":"This is an error","timestamp":' . time() . '}' . PHP_EOL;
            $logger->log("This is an error", Logger::ERROR);
            $expected .= '{"type":"ERROR","message":"This is another error","timestamp":' . time() . '}' . PHP_EOL;
            $logger->error("This is another error");
            $I->amInPath($this->logPath);
            $I->openFile($file1);
            $I->seeFileContentsEqual($expected);
            $I->deleteFile($file1);
            $I->openFile($file2);
            $I->seeFileContentsEqual($expected);
            $I->deleteFile($file2);
        });
    }
FileTest