1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 17:16:18 +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

@@ -27,6 +27,9 @@ abstract class AbstractHandler implements HandlerInterface
protected $level = Logger::DEBUG;
protected $bubble = false;
/**
* @var FormatterInterface
*/
protected $formatter;
protected $processors = array();
@@ -57,16 +60,12 @@ abstract class AbstractHandler implements HandlerInterface
return false;
}
if ($this->processors) {
foreach ($this->processors as $processor) {
$record = call_user_func($processor, $record);
}
}
$record = $this->processRecord($record);
if (!$this->formatter) {
$this->formatter = $this->getDefaultFormatter();
}
$record = $this->formatter->format($record);
$record['message'] = $this->formatter->format($record);
$this->write($record);
@@ -188,4 +187,21 @@ abstract class AbstractHandler implements HandlerInterface
{
return new LineFormatter();
}
/**
* Processes a record.
*
* @param array $record
* @return array
*/
protected function processRecord(array $record)
{
if ($this->processors) {
foreach ($this->processors as $processor) {
$record = call_user_func($processor, $record);
}
}
return $record;
}
}