mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-04 20:27:31 +02:00
Add prefixes to the context and extra record keys. Needed as some processors have the same keys as the the context. Specifically, the IntrospectionProcessor has "line" and "file" that can overwrite an error context "line" and "file".
This commit is contained in:
@@ -60,11 +60,11 @@ class NewRelicHandler extends AbstractProcessingHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($record['context'] as $key => $parameter) {
|
foreach ($record['context'] as $key => $parameter) {
|
||||||
newrelic_add_custom_parameter($key, $parameter);
|
newrelic_add_custom_parameter('context_' . $key, $parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($record['extra'] as $key => $parameter) {
|
foreach ($record['extra'] as $key => $parameter) {
|
||||||
newrelic_add_custom_parameter($key, $parameter);
|
newrelic_add_custom_parameter('extra_' . $key, $parameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ class NewRelicHandlerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$handler = new StubNewRelicHandler();
|
$handler = new StubNewRelicHandler();
|
||||||
$handler->handle($this->getRecord(Logger::ERROR, 'log message', array('a' => 'b')));
|
$handler->handle($this->getRecord(Logger::ERROR, 'log message', array('a' => 'b')));
|
||||||
$this->assertEquals(array('a' => 'b'), self::$customParameters);
|
$this->assertEquals(array('context_a' => 'b'), self::$customParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testThehandlerCanAddExtraParamsToTheNewRelicTrace()
|
public function testThehandlerCanAddExtraParamsToTheNewRelicTrace()
|
||||||
@@ -56,7 +56,7 @@ class NewRelicHandlerTest extends TestCase
|
|||||||
$handler = new StubNewRelicHandler();
|
$handler = new StubNewRelicHandler();
|
||||||
$handler->handle($record);
|
$handler->handle($record);
|
||||||
|
|
||||||
$this->assertEquals(array('c' => 'd'), self::$customParameters);
|
$this->assertEquals(array('extra_c' => 'd'), self::$customParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testThehandlerCanAddExtraContextAndParamsToTheNewRelicTrace()
|
public function testThehandlerCanAddExtraContextAndParamsToTheNewRelicTrace()
|
||||||
@@ -68,8 +68,8 @@ class NewRelicHandlerTest extends TestCase
|
|||||||
$handler->handle($record);
|
$handler->handle($record);
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'a' => 'b',
|
'context_a' => 'b',
|
||||||
'c' => 'd',
|
'extra_c' => 'd',
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals($expected, self::$customParameters);
|
$this->assertEquals($expected, self::$customParameters);
|
||||||
|
Reference in New Issue
Block a user