1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 04:37:38 +02:00

Allow overriding of extra fields and configuring them fully in the constructor, fixes #663

This commit is contained in:
Jordi Boggiano
2015-10-14 14:09:16 +01:00
parent bee7f0dc9c
commit 0a2e4237d3

View File

@@ -24,6 +24,10 @@ class WebProcessor
protected $serverData;
/**
* Default fields
*
* Array is structured as [key in record.extra => key in $serverData]
*
* @var array
*/
protected $extraFields = array(
@@ -36,7 +40,7 @@ class WebProcessor
/**
* @param array|\ArrayAccess $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data
* @param array|null $extraFields Extra field names to be added (all available by default)
* @param array|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer
*/
public function __construct($serverData = null, array $extraFields = null)
{
@@ -49,11 +53,7 @@ class WebProcessor
}
if (null !== $extraFields) {
foreach (array_keys($this->extraFields) as $fieldName) {
if (!in_array($fieldName, $extraFields)) {
unset($this->extraFields[$fieldName]);
}
}
$this->extraFields = $extraFields;
}
}