ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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('Monolog\\'))
 
 __invoke (array $record)
 

Private Attributes

 $level
 
 $skipClassesPartials
 

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('Monolog\\') 
)

Definition at line 33 of file IntrospectionProcessor.php.

34 {
35 $this->level = Logger::toMonologLevel($level);
36 $this->skipClassesPartials = $skipClassesPartials;
37 }
static toMonologLevel($level)
Converts PSR-3 levels to Monolog ones if necessary.
Definition: Logger.php:403

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

+ 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 43 of file IntrospectionProcessor.php.

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 }

Field Documentation

◆ $level

Monolog\Processor\IntrospectionProcessor::$level
private

◆ $skipClassesPartials

Monolog\Processor\IntrospectionProcessor::$skipClassesPartials
private

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