mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-07 21:56:31 +02:00
NewRelic handler: added the app name
This commit is contained in:
@@ -37,6 +37,10 @@ class NewRelicHandler extends AbstractProcessingHandler
|
|||||||
throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler');
|
throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($record['context']['appname'])) {
|
||||||
|
newrelic_set_appname($record['context']['appname']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) {
|
if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) {
|
||||||
newrelic_notice_error($record['message'], $record['context']['exception']);
|
newrelic_notice_error($record['message'], $record['context']['exception']);
|
||||||
unset($record['context']['exception']);
|
unset($record['context']['exception']);
|
||||||
|
@@ -36,6 +36,12 @@ 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')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testThehandlerCanAddTheAppName()
|
||||||
|
{
|
||||||
|
$handler = new StubNewRelicHandler();
|
||||||
|
$handler->handle($this->getRecord(Logger::ERROR, 'log message', array('appname' => 'myApp')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StubNewRelicHandlerWithoutExtension extends NewRelicHandler
|
class StubNewRelicHandlerWithoutExtension extends NewRelicHandler
|
||||||
@@ -59,6 +65,11 @@ function newrelic_notice_error()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function newrelic_set_appname()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function newrelic_add_custom_parameter()
|
function newrelic_add_custom_parameter()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user