|
|
|
@ -3,7 +3,6 @@
|
|
|
|
|
namespace jrosset\ExtendedMonolog;
|
|
|
|
|
|
|
|
|
|
use Monolog\Formatter\LineFormatter;
|
|
|
|
|
use Monolog\LogRecord;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A formater for log files
|
|
|
|
@ -25,18 +24,16 @@ class LogFileFormatter extends LineFormatter {
|
|
|
|
|
/**
|
|
|
|
|
* @inheritDoc
|
|
|
|
|
*/
|
|
|
|
|
public function format (LogRecord $record): string {
|
|
|
|
|
public function format (array $record): string {
|
|
|
|
|
//region Get then remove newlines at record message end (*before* the formatting)
|
|
|
|
|
$messageEndNewlines = '';
|
|
|
|
|
$record = $record->with(
|
|
|
|
|
message: preg_replace_callback(
|
|
|
|
|
'/(?:(?<!\\\\)(?:\\\\[rn]|\\r|\\n))+$/',
|
|
|
|
|
function (array $match) use (&$messageEndNewlines): string {
|
|
|
|
|
$messageEndNewlines = $match[0];
|
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
$this->normalize($record->message)
|
|
|
|
|
)
|
|
|
|
|
$record['message'] = preg_replace_callback(
|
|
|
|
|
'/(?:(?<!\\\\)(?:\\\\[rn]|\\r|\\n))+$/',
|
|
|
|
|
function (array $match) use (&$messageEndNewlines): string {
|
|
|
|
|
$messageEndNewlines = $match[0];
|
|
|
|
|
return '';
|
|
|
|
|
},
|
|
|
|
|
$this->normalize($record['message'])
|
|
|
|
|
);
|
|
|
|
|
//endregion
|
|
|
|
|
//region Format the record
|
|
|
|
|