mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-06 05:07:36 +02:00
Remove substitution for not defined variables
If variable in extra or context isn't defined, than placeholder will not not be replaced in format string. This patch remove all not replaced placeholders
This commit is contained in:
@@ -76,6 +76,8 @@ class LineFormatter extends NormalizerFormatter
|
||||
}
|
||||
}
|
||||
|
||||
$output = preg_replace('/%extra\..+?%/', '', $output);
|
||||
|
||||
foreach ($vars['context'] as $var => $val) {
|
||||
if (false !== strpos($output, '%context.'.$var.'%')) {
|
||||
$output = str_replace('%context.'.$var.'%', $this->stringify($val), $output);
|
||||
@@ -83,6 +85,8 @@ class LineFormatter extends NormalizerFormatter
|
||||
}
|
||||
}
|
||||
|
||||
$output = preg_replace('/%context\..+?%/', '', $output);
|
||||
|
||||
if ($this->ignoreEmptyContextAndExtra) {
|
||||
if (empty($vars['context'])) {
|
||||
unset($vars['context']);
|
||||
|
Reference in New Issue
Block a user