Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Log / Processor / Backtrace.php
blobe827bbfcade4ed1485093191f9de62bbdabcf0e5
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Log\Processor;
12 class Backtrace implements ProcessorInterface
14 /**
15 * Maximum stack level of backtrace (PHP > 5.4.0)
16 * @var int
18 protected $traceLimit = 10;
20 /**
21 * Classes within this namespace in the stack are ignored
22 * @var string
24 protected $ignoredNamespace = 'Zend\\Log';
26 /**
27 * Adds the origin of the log() call to the event extras
29 * @param array $event event data
30 * @return array event data
32 public function process(array $event)
34 $trace = $this->getBacktrace();
36 array_shift($trace); // ignore $this->getBacktrace();
37 array_shift($trace); // ignore $this->process()
39 $i = 0;
40 while (isset($trace[$i]['class'])
41 && false !== strpos($trace[$i]['class'], $this->ignoredNamespace)
42 ) {
43 $i++;
46 $origin = array(
47 'file' => isset($trace[$i-1]['file']) ? $trace[$i-1]['file'] : null,
48 'line' => isset($trace[$i-1]['line']) ? $trace[$i-1]['line'] : null,
49 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null,
50 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
53 $extra = $origin;
54 if (isset($event['extra'])) {
55 $extra = array_merge($origin, $event['extra']);
57 $event['extra'] = $extra;
59 return $event;
62 /**
63 * Provide backtrace as slim as posible
65 * @return array:
67 protected function getBacktrace()
69 if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
70 return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $this->traceLimit);
73 if (version_compare(PHP_VERSION, '5.3.6') >= 0) {
74 return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
77 return debug_backtrace();