ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
class.ilTraceProcessor.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
35 {
36  private int $level = 0;
37 
38  public function __construct(int $a_level)
39  {
40  $this->level = $a_level;
41  }
42 
46  public function __invoke(LogRecord $record): LogRecord
47  {
48  if ($record['level'] < $this->level) {
49  return $record;
50  }
51 
52  $trace = debug_backtrace();
53 
54  // shift current method
55  array_shift($trace);
56 
57  // shift internal monolog calls
58  array_shift($trace);
59  array_shift($trace);
60  array_shift($trace);
61  array_shift($trace);
62 
63  if (is_array($trace) && count($trace)) {
64  $trace_info =
65  ($trace[0]['class'] ?? '') . '::' .
66  ($trace[0]['function'] ?? '') . ':' .
67  ($trace[0]['line'] ?? '');
68  $record['extra'] = array_merge(
69  $record['extra'],
70  array('trace' => $trace_info)
71  );
72  }
73  return $record;
74  }
75 }
__invoke(LogRecord $record)