ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
IntrospectionProcessor.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Monolog package.
5  *
6  * (c) Jordi Boggiano <j.boggiano@seld.be>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Monolog\Processor;
13 
14 use Monolog\Logger;
15 
28 {
29  private $level;
30 
32 
33  public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array('Monolog\\'))
34  {
35  $this->level = Logger::toMonologLevel($level);
36  $this->skipClassesPartials = $skipClassesPartials;
37  }
38 
43  public function __invoke(array $record)
44  {
45  // return if the level is not high enough
46  if ($record['level'] < $this->level) {
47  return $record;
48  }
49 
50  $trace = debug_backtrace();
51 
52  // skip first since it's always the current method
53  array_shift($trace);
54  // the call_user_func call is also skipped
55  array_shift($trace);
56 
57  $i = 0;
58 
59  while (isset($trace[$i]['class'])) {
60  foreach ($this->skipClassesPartials as $part) {
61  if (strpos($trace[$i]['class'], $part) !== false) {
62  $i++;
63  continue 2;
64  }
65  }
66  break;
67  }
68 
69  // we should have the call source now
70  $record['extra'] = array_merge(
71  $record['extra'],
72  array(
73  'file' => isset($trace[$i-1]['file']) ? $trace[$i-1]['file'] : null,
74  'line' => isset($trace[$i-1]['line']) ? $trace[$i-1]['line'] : null,
75  'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null,
76  'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
77  )
78  );
79 
80  return $record;
81  }
82 }
Injects line/file:class/function where the log message came from.
const DEBUG
Detailed debug information.
Definition: Logger.php:32
static toMonologLevel($level)
Converts PSR-3 levels to Monolog ones if necessary.
Definition: Logger.php:403
__construct($level=Logger::DEBUG, array $skipClassesPartials=array('Monolog\\'))