Skip to content

Commit

Permalink
Merge branch '1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Jul 8, 2020
2 parents 0ae6fd8 + c3a05db commit 84342aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Monolog/Processor/WebProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function __construct($serverData = null, array $extraFields = null)
throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
}

if (isset($this->serverData['UNIQUE_ID'])) {
$this->extraFields['unique_id'] = 'UNIQUE_ID';
}

if (null !== $extraFields) {
if (isset($extraFields[0])) {
foreach (array_keys($this->extraFields) as $fieldName) {
Expand Down Expand Up @@ -91,10 +95,6 @@ private function appendExtraFields(array $extra): array
$extra[$extraName] = $this->serverData[$serverName] ?? null;
}

if (isset($this->serverData['UNIQUE_ID'])) {
$extra['unique_id'] = $this->serverData['UNIQUE_ID'];
}

return $extra;
}
}
13 changes: 13 additions & 0 deletions tests/Monolog/Processor/WebProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ public function testProcessorAddsOnlyRequestedExtraFields()
$this->assertSame(['url' => 'A', 'http_method' => 'C'], $record['extra']);
}

public function testProcessorAddsOnlyRequestedExtraFieldsIncludingOptionalFields()
{
$server = array(
'REQUEST_URI' => 'A',
'UNIQUE_ID' => 'X',
);

$processor = new WebProcessor($server, array('url'));
$record = $processor($this->getRecord());

$this->assertSame(array('url' => 'A'), $record['extra']);
}

public function testProcessorConfiguringOfExtraFields()
{
$server = [
Expand Down

0 comments on commit 84342aa

Please sign in to comment.