summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJordi Boggiano <j.boggiano@seld.be>2016-11-13 20:17:30 +0100
committerJordi Boggiano <j.boggiano@seld.be>2016-11-13 20:17:30 +0100
commitcc8a013611b8daefbf3f8ef9803ee49289ad9dc2 (patch)
tree5fcd6aac0f06d8bd8b7db323f6e2571763681b4c /src
parent79bf752d27651362d335b8330b11647cfd0a6776 (diff)
downloadmonolog-cc8a013611b8daefbf3f8ef9803ee49289ad9dc2.zip
monolog-cc8a013611b8daefbf3f8ef9803ee49289ad9dc2.tar.gz
monolog-cc8a013611b8daefbf3f8ef9803ee49289ad9dc2.tar.bz2
Optimize removal of leftover extra/context placeholders, refs #866
Diffstat (limited to 'src')
-rw-r--r--src/Monolog/Formatter/LineFormatter.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Monolog/Formatter/LineFormatter.php b/src/Monolog/Formatter/LineFormatter.php
index 7122319..8ffe601 100644
--- a/src/Monolog/Formatter/LineFormatter.php
+++ b/src/Monolog/Formatter/LineFormatter.php
@@ -76,7 +76,6 @@ class LineFormatter extends NormalizerFormatter
}
}
- $output = preg_replace('/%extra\..+?%/', '', $output);
foreach ($vars['context'] as $var => $val) {
if (false !== strpos($output, '%context.'.$var.'%')) {
@@ -85,8 +84,6 @@ class LineFormatter extends NormalizerFormatter
}
}
- $output = preg_replace('/%context\..+?%/', '', $output);
-
if ($this->ignoreEmptyContextAndExtra) {
if (empty($vars['context'])) {
unset($vars['context']);
@@ -105,6 +102,11 @@ class LineFormatter extends NormalizerFormatter
}
}
+ // remove leftover %extra.xxx% and %context.xxx% if any
+ if (false !== strpos($output, '%')) {
+ $output = preg_replace('/%(?:extra|context)\..+?%/', '', $output);
+ }
+
return $output;
}