mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-21 08:36:33 +02:00
WebProcessor: option to add only requested extra fields, instead of always adding all available
This commit is contained in:
@@ -35,9 +35,10 @@ class WebProcessor
|
||||
);
|
||||
|
||||
/**
|
||||
* @param mixed $serverData array or object w/ ArrayAccess that provides access to the $_SERVER data
|
||||
* @param mixed $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)
|
||||
*/
|
||||
public function __construct($serverData = null)
|
||||
public function __construct($serverData = null, array $extraFields = null)
|
||||
{
|
||||
if (null === $serverData) {
|
||||
$this->serverData =& $_SERVER;
|
||||
@@ -46,6 +47,14 @@ class WebProcessor
|
||||
} else {
|
||||
throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
|
||||
}
|
||||
|
||||
if (null !== $extraFields) {
|
||||
foreach (array_keys($this->extraFields) as $fieldName) {
|
||||
if (!in_array($fieldName, $extraFields)) {
|
||||
unset($this->extraFields[$fieldName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user