mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-07 21:56:31 +02:00
Moved the use of the default formatter to the getter to keep the code DRY
This commit is contained in:
@@ -62,10 +62,7 @@ abstract class AbstractHandler implements HandlerInterface
|
|||||||
|
|
||||||
$record = $this->processRecord($record);
|
$record = $this->processRecord($record);
|
||||||
|
|
||||||
if (!$this->formatter) {
|
$record['message'] = $this->getFormatter()->format($record);
|
||||||
$this->formatter = $this->getDefaultFormatter();
|
|
||||||
}
|
|
||||||
$record['message'] = $this->formatter->format($record);
|
|
||||||
|
|
||||||
$this->write($record);
|
$this->write($record);
|
||||||
|
|
||||||
@@ -120,6 +117,10 @@ abstract class AbstractHandler implements HandlerInterface
|
|||||||
*/
|
*/
|
||||||
public function getFormatter()
|
public function getFormatter()
|
||||||
{
|
{
|
||||||
|
if (!$this->formatter) {
|
||||||
|
$this->formatter = $this->getDefaultFormatter();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->formatter;
|
return $this->formatter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,10 +33,7 @@ abstract class MailHandler extends AbstractHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($messages)) {
|
if (!empty($messages)) {
|
||||||
if (!$this->formatter) {
|
$this->send($this->getFormatter()->formatBatch($messages));
|
||||||
$this->formatter = $this->getDefaultFormatter();
|
|
||||||
}
|
|
||||||
$this->send($this->formatter->formatBatch($messages));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user