ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Monolog\Processor\IntrospectionProcessor Class Reference

Injects line/file:class/function where the log message came from. More...

+ Collaboration diagram for Monolog\Processor\IntrospectionProcessor:

Public Member Functions

 __construct ($level=Logger::DEBUG, array $skipClassesPartials=array(), $skipStackFramesCount=0)
 
 __invoke (array $record)
 

Private Member Functions

 isTraceClassOrSkippedFunction (array $trace, $index)
 

Private Attributes

 $level
 
 $skipClassesPartials
 
 $skipStackFramesCount
 
 $skipFunctions
 

Detailed Description

Injects line/file:class/function where the log message came from.

Warning: This only works if the handler processes the logs directly. If you put the processor on a handler that is behind a FingersCrossedHandler for example, the processor will only be called once the trigger level is reached, and all the log records will have the same file/line/.. data from the call that triggered the FingersCrossedHandler.

Author
Jordi Boggiano j.bog.nosp@m.gian.nosp@m.o@sel.nosp@m.d.be

Definition at line 27 of file IntrospectionProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Processor\IntrospectionProcessor::__construct (   $level = Logger::DEBUG,
array  $skipClassesPartials = array(),
  $skipStackFramesCount = 0 
)

Definition at line 40 of file IntrospectionProcessor.php.

References Monolog\Processor\IntrospectionProcessor\$level, Monolog\Processor\IntrospectionProcessor\$skipClassesPartials, Monolog\Processor\IntrospectionProcessor\$skipStackFramesCount, array, and Monolog\Logger\toMonologLevel().

41  {
42  $this->level = Logger::toMonologLevel($level);
43  $this->skipClassesPartials = array_merge(array('Monolog\\'), $skipClassesPartials);
44  $this->skipStackFramesCount = $skipStackFramesCount;
45  }
static toMonologLevel($level)
Converts PSR-3 levels to Monolog ones if necessary.
Definition: Logger.php:473
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Member Function Documentation

◆ __invoke()

Monolog\Processor\IntrospectionProcessor::__invoke ( array  $record)
Parameters
array$record
Returns
array

Definition at line 51 of file IntrospectionProcessor.php.

References $i, Monolog\Processor\IntrospectionProcessor\$skipStackFramesCount, array, and Monolog\Processor\IntrospectionProcessor\isTraceClassOrSkippedFunction().

52  {
53  // return if the level is not high enough
54  if ($record['level'] < $this->level) {
55  return $record;
56  }
57 
58  $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
59 
60  // skip first since it's always the current method
61  array_shift($trace);
62  // the call_user_func call is also skipped
63  array_shift($trace);
64 
65  $i = 0;
66 
67  while ($this->isTraceClassOrSkippedFunction($trace, $i)) {
68  if (isset($trace[$i]['class'])) {
69  foreach ($this->skipClassesPartials as $part) {
70  if (strpos($trace[$i]['class'], $part) !== false) {
71  $i++;
72  continue 2;
73  }
74  }
75  } elseif (in_array($trace[$i]['function'], $this->skipFunctions)) {
76  $i++;
77  continue;
78  }
79 
80  break;
81  }
82 
84 
85  // we should have the call source now
86  $record['extra'] = array_merge(
87  $record['extra'],
88  array(
89  'file' => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null,
90  'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null,
91  'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null,
92  'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
93  )
94  );
95 
96  return $record;
97  }
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

◆ isTraceClassOrSkippedFunction()

Monolog\Processor\IntrospectionProcessor::isTraceClassOrSkippedFunction ( array  $trace,
  $index 
)
private

Definition at line 99 of file IntrospectionProcessor.php.

References $index.

Referenced by Monolog\Processor\IntrospectionProcessor\__invoke().

100  {
101  if (!isset($trace[$index])) {
102  return false;
103  }
104 
105  return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions);
106  }
$index
Definition: metadata.php:60
+ Here is the caller graph for this function:

Field Documentation

◆ $level

Monolog\Processor\IntrospectionProcessor::$level
private

◆ $skipClassesPartials

Monolog\Processor\IntrospectionProcessor::$skipClassesPartials
private

◆ $skipFunctions

Monolog\Processor\IntrospectionProcessor::$skipFunctions
private
Initial value:
'call_user_func',
'call_user_func_array',
)

Definition at line 35 of file IntrospectionProcessor.php.

◆ $skipStackFramesCount

Monolog\Processor\IntrospectionProcessor::$skipStackFramesCount
private

The documentation for this class was generated from the following file: