From ff43ef98603c23b198e658ba192053be243f66db Mon Sep 17 00:00:00 2001 From: Artur Geraschenko Date: Thu, 12 Dec 2013 21:27:31 +0300 Subject: [PATCH] Init IntrospectionProcessor with skip classes parameter with fixed array notation Logger maybe use in other debug classes and I must be able to skip my debug classes. For example: new IntrospectionProcessor(Logger::DEBUG, array('Monolog\\', 'Debug')) --- .../Processor/IntrospectionProcessor.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Monolog/Processor/IntrospectionProcessor.php b/src/Monolog/Processor/IntrospectionProcessor.php index a7de5d8d..26007aa8 100644 --- a/src/Monolog/Processor/IntrospectionProcessor.php +++ b/src/Monolog/Processor/IntrospectionProcessor.php @@ -28,9 +28,12 @@ class IntrospectionProcessor { private $level; - public function __construct($level = Logger::DEBUG) + private $skipClassesPartials; + + public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array('Monolog\\')) { $this->level = $level; + $this->skipClassesPartials = $skipClassesPartials; } /** @@ -52,9 +55,19 @@ class IntrospectionProcessor array_shift($trace); $i = 0; - while (isset($trace[$i]['class']) && false !== strpos($trace[$i]['class'], 'Monolog\\')) { - $i++; - } + + while (isset($trace[$i]['class'])) + { + foreach ($this->skipClassesPartials as $part) + { + if (strpos($trace[$i]['class'], $part) !== false) + { + $i++; + continue 2; + } + } + break; + } // we should have the call source now $record['extra'] = array_merge(