mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-30 01:40:30 +02:00
Add unique_id to extra data only if present in the server environment
This commit is contained in:
@@ -54,10 +54,13 @@ class WebProcessor
|
||||
'http_method' => isset($this->serverData['REQUEST_METHOD']) ? $this->serverData['REQUEST_METHOD'] : null,
|
||||
'server' => isset($this->serverData['SERVER_NAME']) ? $this->serverData['SERVER_NAME'] : null,
|
||||
'referrer' => isset($this->serverData['HTTP_REFERER']) ? $this->serverData['HTTP_REFERER'] : null,
|
||||
'unique_id' => isset($this->serverData['UNIQUE_ID']) ? $this->serverData['UNIQUE_ID'] : null,
|
||||
)
|
||||
);
|
||||
|
||||
if (isset($this->serverData['UNIQUE_ID'])) {
|
||||
$record['extra']['unique_id'] = $this->serverData['UNIQUE_ID'];
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
}
|
||||
|
@@ -60,6 +60,19 @@ class WebProcessorTest extends TestCase
|
||||
$this->assertNull($record['extra']['referrer']);
|
||||
}
|
||||
|
||||
public function testProcessorDoesNotAddUniqueIdIfNotPresent()
|
||||
{
|
||||
$server = array(
|
||||
'REQUEST_URI' => 'A',
|
||||
'REMOTE_ADDR' => 'B',
|
||||
'REQUEST_METHOD' => 'C',
|
||||
'SERVER_NAME' => 'F',
|
||||
);
|
||||
$processor = new WebProcessor($server);
|
||||
$record = $processor($this->getRecord());
|
||||
$this->assertFalse(isset($record['extra']['unique_id']));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException UnexpectedValueException
|
||||
*/
|
||||
|
Reference in New Issue
Block a user