mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-22 09:06:10 +02:00
Changed the FormatterInterface to return only the formatted message and added a batch formatting method
This commit is contained in:
@@ -18,7 +18,7 @@ use Monolog\Logger;
|
||||
*
|
||||
* @author Eric Clemmons (@ericclemmons) <eric@uxdriven.com>
|
||||
*/
|
||||
class WildfireFormatter extends LineFormatter implements FormatterInterface
|
||||
class WildfireFormatter extends LineFormatter
|
||||
{
|
||||
/**
|
||||
* Similar to LineFormatter::SIMPLE_FORMAT, except without the "[%datetime%]"
|
||||
@@ -43,7 +43,7 @@ class WildfireFormatter extends LineFormatter implements FormatterInterface
|
||||
public function format(array $record)
|
||||
{
|
||||
// Format record according with LineFormatter
|
||||
$formatted = parent::format($record);
|
||||
$message = parent::format($record);
|
||||
|
||||
// Create JSON object describing the appearance of the message in the console
|
||||
$json = json_encode(array(
|
||||
@@ -52,17 +52,19 @@ class WildfireFormatter extends LineFormatter implements FormatterInterface
|
||||
'File' => '',
|
||||
'Line' => '',
|
||||
),
|
||||
$formatted['message'],
|
||||
$message,
|
||||
));
|
||||
|
||||
// The message itself is a serialization of the above JSON object + it's length
|
||||
$formatted['message'] = sprintf(
|
||||
return sprintf(
|
||||
'%s|%s|',
|
||||
strlen($json),
|
||||
$json
|
||||
);
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
|
||||
public function formatBatch(array $records)
|
||||
{
|
||||
throw new \BadMethodCallException('Batch formatting does not make sense for the WildfireFormatter');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user