log() public method

Logs a message.
public log ( integer $code, string $message ) : void
$code integer Log level code.
$message string Message to log.
return void
Exemplo n.º 1
0
 public function testLogMessageWithCustomFormatter()
 {
     $logger = new Logger(new PlainTextFormatter());
     $logger->log('Foo Bar', new XmlFormatter());
     $logger->log('Bar Foo', new XmlFormatter());
     $logs = $logger->getLogs();
     $this->assertCount(2, $logs);
     $this->assertRegExp('#<log time="\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}">Foo Bar<\\/log>#', $logs[0]);
     $this->assertRegExp('#<log time="\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}">Bar Foo<\\/log>#', $logs[1]);
 }
Exemplo n.º 2
0
<?php

require '../vendor/autoload.php';
use Logger\Logger;
use Logger\LogLevel;
$log = new Logger(include '../src/Logger/config.php');
$log->log(LogLevel::ALERT, 'Testing logs:' . (isset($_GET['msg']) ? $_GET['msg'] : ''));
$log->debug('Testing logs');
$log->warning('WARNING Message ');
$log->error('Error Message ');