ILIAS  release_8 Revision v8.24
class.ilTraceProcessor.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
5
18{
19 private int $level = 0;
20
21 public function __construct(int $a_level)
22 {
23 $this->level = $a_level;
24 }
25
29 public function __invoke(array $record): array
30 {
31 if ($record['level'] < $this->level) {
32 return $record;
33 }
34
35 $trace = debug_backtrace();
36
37 // shift current method
38 array_shift($trace);
39
40 // shift internal monolog calls
41 array_shift($trace);
42 array_shift($trace);
43 array_shift($trace);
44 array_shift($trace);
45
46 if (is_array($trace) && count($trace)) {
47 $trace_info =
48 ($trace[0]['class'] ?? '') . '::' .
49 ($trace[0]['function'] ?? '') . ':' .
50 ($trace[0]['line'] ?? '');
51 $record['extra'] = array_merge(
52 $record['extra'],
53 array('trace' => $trace_info)
54 );
55 }
56 return $record;
57 }
58}