ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Monolog\Processor\WebProcessor Class Reference

Injects url/method and remote IP of the current web request in all records. More...

+ Inheritance diagram for Monolog\Processor\WebProcessor:
+ Collaboration diagram for Monolog\Processor\WebProcessor:

Public Member Functions

 __construct ($serverData=null, array $extraFields=null)
 
 __invoke (array $record)
 
 addExtraField ($extraName, $serverName)
 

Protected Attributes

 $serverData
 
 $extraFields
 

Private Member Functions

 appendExtraFields (array $extra)
 

Detailed Description

Injects url/method and remote IP of the current web request in all records.

Author
Jordi Boggiano j.bog.nosp@m.gian.nosp@m.o@sel.nosp@m.d.be

Definition at line 19 of file WebProcessor.php.

Constructor & Destructor Documentation

◆ __construct()

Monolog\Processor\WebProcessor::__construct (   $serverData = null,
array  $extraFields = null 
)
Parameters
array | \ArrayAccess$serverDataArray or object w/ ArrayAccess that provides access to the $_SERVER data
array | null$extraFieldsField names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer

Definition at line 45 of file WebProcessor.php.

References $_SERVER, Monolog\Processor\WebProcessor\$extraFields, and Monolog\Processor\WebProcessor\$serverData.

46  {
47  if (null === $serverData) {
48  $this->serverData = &$_SERVER;
49  } elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) {
50  $this->serverData = $serverData;
51  } else {
52  throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
53  }
54 
55  if (null !== $extraFields) {
56  if (isset($extraFields[0])) {
57  foreach (array_keys($this->extraFields) as $fieldName) {
58  if (!in_array($fieldName, $extraFields)) {
59  unset($this->extraFields[$fieldName]);
60  }
61  }
62  } else {
63  $this->extraFields = $extraFields;
64  }
65  }
66  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

Member Function Documentation

◆ __invoke()

Monolog\Processor\WebProcessor::__invoke ( array  $record)
Parameters
array$record
Returns
array

Implements Monolog\Processor\ProcessorInterface.

Definition at line 72 of file WebProcessor.php.

References Monolog\Processor\WebProcessor\appendExtraFields().

73  {
74  // skip processing if for some reason request data
75  // is not present (CLI or wonky SAPIs)
76  if (!isset($this->serverData['REQUEST_URI'])) {
77  return $record;
78  }
79 
80  $record['extra'] = $this->appendExtraFields($record['extra']);
81 
82  return $record;
83  }
+ Here is the call graph for this function:

◆ addExtraField()

Monolog\Processor\WebProcessor::addExtraField (   $extraName,
  $serverName 
)
Parameters
string$extraName
string$serverName
Returns
$this

Definition at line 90 of file WebProcessor.php.

91  {
92  $this->extraFields[$extraName] = $serverName;
93 
94  return $this;
95  }

◆ appendExtraFields()

Monolog\Processor\WebProcessor::appendExtraFields ( array  $extra)
private
Parameters
array$extra
Returns
array

Definition at line 101 of file WebProcessor.php.

Referenced by Monolog\Processor\WebProcessor\__invoke().

102  {
103  foreach ($this->extraFields as $extraName => $serverName) {
104  $extra[$extraName] = isset($this->serverData[$serverName]) ? $this->serverData[$serverName] : null;
105  }
106 
107  if (isset($this->serverData['UNIQUE_ID'])) {
108  $extra['unique_id'] = $this->serverData['UNIQUE_ID'];
109  }
110 
111  return $extra;
112  }
+ Here is the caller graph for this function:

Field Documentation

◆ $extraFields

Monolog\Processor\WebProcessor::$extraFields
protected
Initial value:
= array(
'url' => 'REQUEST_URI',
'ip' => 'REMOTE_ADDR',
'http_method' => 'REQUEST_METHOD',
'server' => 'SERVER_NAME',
'referrer' => 'HTTP_REFERER',
)

Definition at line 33 of file WebProcessor.php.

Referenced by Monolog\Processor\WebProcessor\__construct().

◆ $serverData

Monolog\Processor\WebProcessor::$serverData
protected

Definition at line 24 of file WebProcessor.php.

Referenced by Monolog\Processor\WebProcessor\__construct().


The documentation for this class was generated from the following file: