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

testLoggerAdapterFileNewFormatLogsCorrectly() public method

Tests new format logs correctly
Since: 2012-09-17
Author: Nikos Dimopoulos ([email protected])
    public function testLoggerAdapterFileNewFormatLogsCorrectly()
    {
        $fileName = $this->tester->getNewFileName('log', 'log');
        $logger = new File($this->logPath . $fileName);
        $formatter = new Line('%type%|%date%|%message%');
        $logger->setFormatter($formatter);
        $logger->log('Hello');
        $logger->close();
        $contents = \file($this->logPath . $fileName);
        $message = explode('|', $contents[0]);
        $this->tester->cleanFile($this->logPath, $fileName);
        $this->assertEquals('DEBUG', $message[0], 'New format, type not set correctly');
        $this->assertEquals('Hello' . PHP_EOL, $message[2], 'New format, message not set correctly');
    }
FileTest