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 / RequestId.php
blob61520b21203e968c7289ddd3308a9f2950c365ed
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 use Zend\Console\Console;
14 class RequestId implements ProcessorInterface
16 /**
17 * Request identifier
19 * @var string
21 protected $identifier;
23 /**
24 * Adds a identifier for the request to the log.
26 * This enables to filter the log for messages belonging to a specific request
28 * @param array $event event data
29 * @return array event data
31 public function process(array $event)
33 if (!isset($event['extra'])) {
34 $event['extra'] = array();
37 $event['extra']['requestId'] = $this->getIdentifier();
38 return $event;
41 /**
42 * Provide unique identifier for a request
44 * @return string
46 protected function getIdentifier()
48 if ($this->identifier) {
49 return $this->identifier;
52 $requestTime = (version_compare(PHP_VERSION, '5.4.0') >= 0)
53 ? $_SERVER['REQUEST_TIME_FLOAT']
54 : $_SERVER['REQUEST_TIME'];
56 if (Console::isConsole()) {
57 $this->identifier = md5($requestTime);
58 return $this->identifier;
61 if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
62 $this->identifier = md5($requestTime . $_SERVER['HTTP_X_FORWARDED_FOR']);
63 return $this->identifier;
66 $this->identifier = md5($requestTime . $_SERVER['REMOTE_ADDR']);
67 return $this->identifier;