1
0
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:
Pavel Golovin
2016-10-10 18:57:57 +03:00
committed by GitHub
parent 214b8ef34b
commit ccb4aeba21

View File

@@ -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']);