mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-31 10:20:14 +02:00
Restore filtering behavior, refs #663
This commit is contained in:
@@ -53,7 +53,15 @@ class WebProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $extraFields) {
|
if (null !== $extraFields) {
|
||||||
$this->extraFields = $extraFields;
|
if (isset($extraFields[0])) {
|
||||||
|
foreach (array_keys($this->extraFields) as $fieldName) {
|
||||||
|
if (!in_array($fieldName, $extraFields)) {
|
||||||
|
unset($this->extraFields[$fieldName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->extraFields = $extraFields;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -88,6 +88,21 @@ class WebProcessorTest extends TestCase
|
|||||||
$this->assertSame(array('url' => 'A', 'http_method' => 'C'), $record['extra']);
|
$this->assertSame(array('url' => 'A', 'http_method' => 'C'), $record['extra']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProcessorConfiguringOfExtraFields()
|
||||||
|
{
|
||||||
|
$server = array(
|
||||||
|
'REQUEST_URI' => 'A',
|
||||||
|
'REMOTE_ADDR' => 'B',
|
||||||
|
'REQUEST_METHOD' => 'C',
|
||||||
|
'SERVER_NAME' => 'F',
|
||||||
|
);
|
||||||
|
|
||||||
|
$processor = new WebProcessor($server, array('url' => 'REMOTE_ADDR'));
|
||||||
|
$record = $processor($this->getRecord());
|
||||||
|
|
||||||
|
$this->assertSame(array('url' => 'B'), $record['extra']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException UnexpectedValueException
|
* @expectedException UnexpectedValueException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user