1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-19 23:56:17 +02:00

Tested WebProcessor

This commit is contained in:
Jordi Boggiano
2011-06-29 18:58:26 +02:00
parent c465a5dd02
commit 78a26a3f4f
2 changed files with 58 additions and 3 deletions

View File

@@ -18,6 +18,22 @@ namespace Monolog\Processor;
*/
class WebProcessor
{
protected $serverData;
/**
* @param mixed $serverData array or object w/ ArrayAccess that provides access to the $_SERVER data
*/
public function __construct($serverData = null)
{
if (null === $serverData) {
$this->serverData =& $_SERVER;
} elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) {
$this->serverData = $serverData;
} else {
throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
}
}
/**
* @param array $record
* @param HandlerInterface $handler
@@ -28,9 +44,9 @@ class WebProcessor
$record['extra'] = array_merge(
$record['extra'],
array(
'url' => $_SERVER['REQUEST_URI'],
'ip' => $_SERVER['REMOTE_ADDR'],
'method' => $_SERVER['REQUEST_METHOD'],
'url' => $this->serverData['REQUEST_URI'],
'ip' => $this->serverData['REMOTE_ADDR'],
'http_method' => $this->serverData['REQUEST_METHOD'],
)
);