/** * 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); }); }
public function error() { $this->logger->error($this->getMessage(func_get_args())); }
<?php use Phalcon\Logger, Phalcon\Logger\Multiple as MultipleStream, Phalcon\Logger\Adapter\File as FileAdapter, Phalcon\Logger\Adapter\Stream as StreamAdapter; $logger = new MultipleStream(); $logger->push(new FileAdapter('test.log')); $logger->push(new StreamAdapter('php://stdout')); $logger->log("This is a message"); $logger->log("This is an error", Logger::ERROR); $logger->error("This is another error");
public function error($message, array $context = null) { parent::error($message, $context); }