neeckeloo/NewRelic — pull request #5 by bnkr (2014-01-18 16:20:24+00:00)
Title: Send original exception object to newrelic log

I use the 'extra' part of the log event to give the exception to the log writer. This means we can pass the exception object itself which will mean the error type in newrelic is \My\Own\Exception rather than a NoticedError.

I used getMessage for the log message since the backtrace makes the log pretty unreadable when using __string (and is redundant since the backtrace is always included). Unfortunately newrelic seems to drop the point of call for the exception from its backtrace so I added in getLine and getFile too. Not particularly optimal, but I think it's newrelic's behaviour that's at fault here.

Finally I changed the name of the Logger service to something less likely to conflict with application code. It seems to be the convention for applications to name their services with the name of the class so it seems appropriate for a library module to have a name spaced name.

It would probably be better to write a Listener\ErrorListener as has been done for the other events in this module because then you can cover the event with tests. I didn't realise I could do this until after I'd patched but if you'd like that let me know and I'll refactor it.