PluginProbe
ManageWP Worker / 4.9.25
ManageWP Worker v4.9.25
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / src / Monolog / Processor / WebProcessor.php

WebProcessor.php in ManageWP Worker 4.9.25, at src/Monolog/Processor/WebProcessor.php

66 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 /**
13 * Injects url/method and remote IP of the current web request in all records
14 *
15 * @author Jordi Boggiano <j.boggiano@seld.be>
16 */
17 class Monolog_Processor_WebProcessor implements Monolog_Processor_ProcessorInterface
18 {
19 protected $serverData;
20
21 /**
22 * @param mixed $serverData array or object w/ ArrayAccess that provides access to the $_SERVER data
23 */
24 public function __construct($serverData = null)
25 {
26 if (null === $serverData) {
27 $this->serverData = & $_SERVER;
28 } elseif (is_array($serverData) || $serverData instanceof ArrayAccess) {
29 $this->serverData = $serverData;
30 } else {
31 throw new UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
32 }
33 }
34
35 /**
36 * @param array $record
37 *
38 * @return array
39 */
40 public function callback(array $record)
41 {
42 // skip processing if for some reason request data
43 // is not present (CLI or wonky SAPIs)
44 if (!isset($this->serverData['REQUEST_URI'])) {
45 return $record;
46 }
47
48 $record['extra'] = array_merge(
49 $record['extra'],
50 array(
51 'url' => $this->serverData['REQUEST_URI'],
52 'ip' => isset($this->serverData['REMOTE_ADDR']) ? $this->serverData['REMOTE_ADDR'] : null,
53 'http_method' => isset($this->serverData['REQUEST_METHOD']) ? $this->serverData['REQUEST_METHOD'] : null,
54 'server' => isset($this->serverData['SERVER_NAME']) ? $this->serverData['SERVER_NAME'] : null,
55 'referrer' => isset($this->serverData['HTTP_REFERER']) ? $this->serverData['HTTP_REFERER'] : null,
56 )
57 );
58
59 if (isset($this->serverData['UNIQUE_ID'])) {
60 $record['extra']['unique_id'] = $this->serverData['UNIQUE_ID'];
61 }
62
63 return $record;
64 }
65 }
66