kusebauch/nette-new-relic-logger

This package is abandoned and no longer maintained. No replacement package was suggested.

Logger decorator to New Relic for Nette Framework and Tracy

1.0.1 2016-05-29 01:27 UTC

This package is not auto-updated.

Last update: 2020-11-16 11:24:40 UTC


README

Logging application requests

Logs all requests to Nette application and records application exceptions other than 404s. But does not record errors in the code.

  1. with running only when your NewRelic is
  • installed
  • enabled
  • configured with Bootstrap::setup()
$application = new Application();
\Kusebauch\NetteNewRelicLogger\Bootstrap::addOnError(['\Kusebauch\NetteNewRelicLogger\Utils', onAppError], $application);
\Kusebauch\NetteNewRelicLogger\Bootstrap::addOnRequest(['\Kusebauch\NetteNewRelicLogger\Utils', onAppRequest], $application);
  1. try to run anyway (will be problematic, if you don't have NewRelic agent installed)
$application = new Application();
$application->onError[] = ['\Kusebauch\NetteNewRelicLogger\Utils', onAppError];
$application->onRequest[] = ['\Kusebauch\NetteNewRelicLogger\Utils', onAppRequest];

Logging application errors

Create a decorator over the current Tracy logger. Your application will keep logging the same way as it was up until now, but on top it will log to New Relic.

$oldLogger = \Tracy\Debugger::getLogger();
$newLogger = new \Kusebauch\NetteNewRelicLogger\Bridges\Tracy\LoggerDecorator($oldLogger);
$newLogger->excludeMessageFunc[] = ['\Kusebauch\NetteNewRelicLogger\Utils', 'noticeLoggerFilter'];
$newLogger->excludeMessageFunc[] = ['\Kusebauch\NetteNewRelicLogger\Utils', 'strictLoggerFilter'];
$newLogger->includeMessageFunc[] = function ($message, $priority) { 
    return in_array($priority, [\Tracy\ILogger::CRITICAL, \Tracy\ILogger::ERROR, \Tracy\ILogger::EXCEPTION]);
};
\Tracy\Debugger::setLogger($newLogger);