ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Monolog\Processor\WebProcessor Class Reference

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

+ 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$extraFieldsExtra field names to be added (all available by default)

Definition at line 41 of file WebProcessor.php.

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

42  {
43  if (null === $serverData) {
44  $this->serverData = &$_SERVER;
45  } elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) {
46  $this->serverData = $serverData;
47  } else {
48  throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
49  }
50 
51  if (null !== $extraFields) {
52  foreach (array_keys($this->extraFields) as $fieldName) {
53  if (!in_array($fieldName, $extraFields)) {
54  unset($this->extraFields[$fieldName]);
55  }
56  }
57  }
58  }
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

Definition at line 64 of file WebProcessor.php.

References Monolog\Processor\WebProcessor\appendExtraFields().

65  {
66  // skip processing if for some reason request data
67  // is not present (CLI or wonky SAPIs)
68  if (!isset($this->serverData['REQUEST_URI'])) {
69  return $record;
70  }
71 
72  $record['extra'] = $this->appendExtraFields($record['extra']);
73 
74  return $record;
75  }
+ 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 82 of file WebProcessor.php.

83  {
84  $this->extraFields[$extraName] = $serverName;
85 
86  return $this;
87  }

◆ appendExtraFields()

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

Definition at line 93 of file WebProcessor.php.

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

94  {
95  foreach ($this->extraFields as $extraName => $serverName) {
96  $extra[$extraName] = isset($this->serverData[$serverName]) ? $this->serverData[$serverName] : null;
97  }
98 
99  if (isset($this->serverData['UNIQUE_ID'])) {
100  $extra['unique_id'] = $this->serverData['UNIQUE_ID'];
101  }
102 
103  return $extra;
104  }
+ 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 29 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: