1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-08 06:06:40 +02:00

Fix NewRelicHandler error when using LineFormatter

This commit is contained in:
Michael Moussa
2016-04-20 11:31:39 -04:00
committed by Jordi Boggiano
parent 79f9492b74
commit 09c4cca32b
2 changed files with 24 additions and 12 deletions

View File

@@ -91,6 +91,7 @@ class NewRelicHandler extends AbstractProcessingHandler
newrelic_notice_error($record['message']);
}
if (isset($record['formatted']['context'])) {
foreach ($record['formatted']['context'] as $key => $parameter) {
if (is_array($parameter) && $this->explodeArrays) {
foreach ($parameter as $paramKey => $paramValue) {
@@ -100,7 +101,9 @@ class NewRelicHandler extends AbstractProcessingHandler
$this->setNewRelicParameter('context_' . $key, $parameter);
}
}
}
if (isset($record['formatted']['extra'])) {
foreach ($record['formatted']['extra'] as $key => $parameter) {
if (is_array($parameter) && $this->explodeArrays) {
foreach ($parameter as $paramKey => $paramValue) {
@@ -111,6 +114,7 @@ class NewRelicHandler extends AbstractProcessingHandler
}
}
}
}
/**
* Checks whether the NewRelic extension is enabled in the system.

View File

@@ -11,6 +11,7 @@
namespace Monolog\Handler;
use Monolog\Formatter\LineFormatter;
use Monolog\TestCase;
use Monolog\Logger;
@@ -104,6 +105,13 @@ class NewRelicHandlerTest extends TestCase
$this->assertEquals($expected, self::$customParameters);
}
public function testThehandlerCanHandleTheRecordsFormattedUsingTheLineFormatter()
{
$handler = new StubNewRelicHandler();
$handler->setFormatter(new LineFormatter());
$handler->handle($this->getRecord(Logger::ERROR));
}
public function testTheAppNameIsNullByDefault()
{
$handler = new StubNewRelicHandler();