1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-31 18:30:15 +02:00

Changed the FormatterInterface to return only the formatted message and added a batch formatting method

This commit is contained in:
Christophe Coevoet
2011-05-07 00:44:20 +02:00
parent d7f98df9ab
commit 7ebcc6420f
9 changed files with 69 additions and 28 deletions

View File

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