Ejemplo 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);
     });
 }
Ejemplo n.º 2
0
 public function error()
 {
     $this->logger->error($this->getMessage(func_get_args()));
 }
Ejemplo n.º 3
0
<?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");
Ejemplo n.º 4
0
 public function error($message, array $context = null)
 {
     parent::error($message, $context);
 }