mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-07 13:46:38 +02:00
Merge pull request #247 from mpdude/patch-1
Add Apache mod_unique_id's identifier in WebProcessor
This commit is contained in:
@@ -57,6 +57,10 @@ class WebProcessor
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isset($this->serverData['UNIQUE_ID'])) {
|
||||||
|
$record['extra']['unique_id'] = $this->serverData['UNIQUE_ID'];
|
||||||
|
}
|
||||||
|
|
||||||
return $record;
|
return $record;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,6 +65,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
|||||||
'REQUEST_METHOD' => '',
|
'REQUEST_METHOD' => '',
|
||||||
'REMOTE_ADDR' => '',
|
'REMOTE_ADDR' => '',
|
||||||
'SERVER_NAME' => '',
|
'SERVER_NAME' => '',
|
||||||
|
'UNIQUE_ID' => '',
|
||||||
)));
|
)));
|
||||||
$handledRecord = null;
|
$handledRecord = null;
|
||||||
$handler->expects($this->once())
|
$handler->expects($this->once())
|
||||||
@@ -74,6 +75,6 @@ class AbstractProcessingHandlerTest extends TestCase
|
|||||||
}))
|
}))
|
||||||
;
|
;
|
||||||
$handler->handle($this->getRecord());
|
$handler->handle($this->getRecord());
|
||||||
$this->assertEquals(5, count($handledRecord['extra']));
|
$this->assertEquals(6, count($handledRecord['extra']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ class WebProcessorTest extends TestCase
|
|||||||
'REQUEST_METHOD' => 'C',
|
'REQUEST_METHOD' => 'C',
|
||||||
'HTTP_REFERER' => 'D',
|
'HTTP_REFERER' => 'D',
|
||||||
'SERVER_NAME' => 'F',
|
'SERVER_NAME' => 'F',
|
||||||
|
'UNIQUE_ID' => 'G',
|
||||||
);
|
);
|
||||||
|
|
||||||
$processor = new WebProcessor($server);
|
$processor = new WebProcessor($server);
|
||||||
@@ -32,6 +33,7 @@ class WebProcessorTest extends TestCase
|
|||||||
$this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']);
|
$this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']);
|
||||||
$this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
|
$this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']);
|
||||||
$this->assertEquals($server['SERVER_NAME'], $record['extra']['server']);
|
$this->assertEquals($server['SERVER_NAME'], $record['extra']['server']);
|
||||||
|
$this->assertEquals($server['UNIQUE_ID'], $record['extra']['unique_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessorDoNothingIfNoRequestUri()
|
public function testProcessorDoNothingIfNoRequestUri()
|
||||||
@@ -58,6 +60,19 @@ class WebProcessorTest extends TestCase
|
|||||||
$this->assertNull($record['extra']['referrer']);
|
$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
|
* @expectedException UnexpectedValueException
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user