1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-29 07:50:05 +02:00

Renamed message to record

This commit is contained in:
Jordi Boggiano
2011-02-25 22:54:01 +01:00
parent efc2bd656b
commit 6c24217c56
16 changed files with 175 additions and 176 deletions

View File

@@ -18,13 +18,13 @@ class JsonFormatterTest extends \PHPUnit_Framework_TestCase
public function testFormat()
{
$formatter = new JsonFormatter();
$message = $formatter->format($msg = array(
$record = $formatter->format($msg = array(
'level_name' => 'WARNING',
'channel' => 'log',
'message' => array('foo'),
'datetime' => new \DateTime,
'extra' => array(),
));
$this->assertEquals(json_encode($msg), $message['message']);
$this->assertEquals(json_encode($msg), $record['message']);
}
}

View File

@@ -18,20 +18,20 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
public function testDefFormatWithString()
{
$formatter = new LineFormatter(null, 'Y-m-d');
$message = $formatter->format(array(
$record = $formatter->format(array(
'level_name' => 'WARNING',
'channel' => 'log',
'message' => 'foo',
'datetime' => new \DateTime,
'extra' => array(),
));
$this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo '."\n", $message['message']);
$this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo '."\n", $record['message']);
}
public function testDefFormatWithArray()
{
$formatter = new LineFormatter(null, 'Y-m-d');
$message = $formatter->format(array(
$record = $formatter->format(array(
'level_name' => 'ERROR',
'channel' => 'meh',
'datetime' => new \DateTime,
@@ -41,19 +41,19 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
'baz' => 'qux',
)
));
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: message(foo: bar, baz: qux) '."\n", $message['message']);
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: message(foo: bar, baz: qux) '."\n", $record['message']);
}
public function testDefFormatExtras()
{
$formatter = new LineFormatter(null, 'Y-m-d');
$message = $formatter->format(array(
$record = $formatter->format(array(
'level_name' => 'ERROR',
'channel' => 'meh',
'datetime' => new \DateTime,
'extra' => array('ip' => '127.0.0.1'),
'message' => 'log',
));
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log extra(ip: 127.0.0.1)'."\n", $message['message']);
$this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log extra(ip: 127.0.0.1)'."\n", $record['message']);
}
}

View File

@@ -19,45 +19,45 @@ class FingersCrossedHandlerTest extends \PHPUnit_Framework_TestCase
{
$test = new TestHandler();
$handler = new FingersCrossedHandler($test);
$handler->handle($this->getMessage(Logger::DEBUG));
$handler->handle($this->getMessage(Logger::INFO));
$this->assertFalse($test->hasDebugMessages());
$this->assertFalse($test->hasInfoMessages());
$handler->handle($this->getMessage(Logger::WARNING));
$this->assertTrue($test->hasInfoMessages());
$this->assertTrue(count($test->getMessages()) === 3);
$handler->handle($this->getRecord(Logger::DEBUG));
$handler->handle($this->getRecord(Logger::INFO));
$this->assertFalse($test->hasDebugRecords());
$this->assertFalse($test->hasInfoRecords());
$handler->handle($this->getRecord(Logger::WARNING));
$this->assertTrue($test->hasInfoRecords());
$this->assertTrue(count($test->getRecords()) === 3);
}
public function testHandleStopsBufferingAfterTrigger()
{
$test = new TestHandler();
$handler = new FingersCrossedHandler($test);
$handler->handle($this->getMessage(Logger::WARNING));
$handler->handle($this->getMessage(Logger::DEBUG));
$this->assertTrue($test->hasWarningMessages());
$this->assertTrue($test->hasDebugMessages());
$handler->handle($this->getRecord(Logger::WARNING));
$handler->handle($this->getRecord(Logger::DEBUG));
$this->assertTrue($test->hasWarningRecords());
$this->assertTrue($test->hasDebugRecords());
}
public function testHandleBufferLimit()
{
$test = new TestHandler();
$handler = new FingersCrossedHandler($test, Logger::WARNING, 2);
$handler->handle($this->getMessage(Logger::DEBUG));
$handler->handle($this->getMessage(Logger::DEBUG));
$handler->handle($this->getMessage(Logger::INFO));
$handler->handle($this->getMessage(Logger::WARNING));
$this->assertTrue($test->hasWarningMessages());
$this->assertTrue($test->hasInfoMessages());
$this->assertFalse($test->hasDebugMessages());
$handler->handle($this->getRecord(Logger::DEBUG));
$handler->handle($this->getRecord(Logger::DEBUG));
$handler->handle($this->getRecord(Logger::INFO));
$handler->handle($this->getRecord(Logger::WARNING));
$this->assertTrue($test->hasWarningRecords());
$this->assertTrue($test->hasInfoRecords());
$this->assertFalse($test->hasDebugRecords());
}
protected function getMessage($level = Logger::WARNING)
protected function getRecord($level = Logger::WARNING)
{
return array(
'level' => $level,
'level_name' => Logger::getLevelName($level),
'channel' => 'log',
'message' => 'foo',
'Record' => 'foo',
'datetime' => new \DateTime,
'extra' => array(),
);

View File

@@ -18,13 +18,13 @@ class NullHandlerTest extends \PHPUnit_Framework_TestCase
public function testHandle()
{
$handler = new NullHandler();
$this->assertTrue($handler->handle($this->getMessage()));
$this->assertTrue($handler->handle($this->getRecord()));
}
public function testHandleLowerLevelMessage()
public function testHandleLowerLevelRecord()
{
$handler = new NullHandler(Logger::WARNING);
$this->assertFalse($handler->handle($this->getMessage(Logger::DEBUG)));
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
}
/**
@@ -33,10 +33,10 @@ class NullHandlerTest extends \PHPUnit_Framework_TestCase
public function testWrite()
{
$handler = new NullHandler();
$handler->write($this->getMessage());
$handler->write($this->getRecord());
}
protected function getMessage($level = Logger::WARNING)
protected function getRecord($level = Logger::WARNING)
{
return array(
'level' => $level,