1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4/**
5 * Logging factory
6 *
7 * This class supplies an implementation for the locator.
8 * The locator will send its output to ist own frame, enabling more flexibility in
9 * the design of the desktop.
10 *
11 * @author Stefan Meyer <smeyer.ilias@gmx.de>
12 * @version $Id$
13 *
14 */
15class ilTraceProcessor
16{
17    private $level = 0;
18
19    public function __construct($a_level)
20    {
21        $this->level = $a_level;
22    }
23
24    /**
25     *
26     * @param array $record
27     * @return array
28     */
29    public function __invoke(array $record)
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        $trace_info = $trace[0]['class'] . '::' . $trace[0]['function'] . ':' . $trace[0]['line'];
47
48        $record['extra'] = array_merge(
49            $record['extra'],
50            array('trace' => $trace_info)
51        );
52        return $record;
53    }
54}
55