[Monolog][RollbarHandler] Exception passed in context override custom log message
Using
rollbar/rollbarv1.8.1rollbar/rollbar-php-symfony-bundlev3.1.2
$this->logger->error(sprintf('Error thrown while projecting event "%s" on projection "%s"', $eventName, get_class($handler)), [
'exception' => $e,
'eventId' => (string)$streamEvent->getEventId() : null,
'eventType' => (string)$streamEvent->getEventType() : null,
]);
When throwing an exception like for instance the following:
throw new \InvalidArgumentException('What the fuck?');
When passing exception in context, Rollbar overrides the message passed as first parameter Error thrown while projecting event... with the one from the exception What the fuck?.
Why is that?
Here is the responsible code: https://github.com/rollbar/rollbar-php/blob/master/src/Monolog/Handler/RollbarHandler.php#L113
This is not convenient because we need to both have custom messages to easily identify logs in item list and the exception trace (If we do not pass the exception we get the correct message but we lose the trace context.).
I totally support this!
Could we at least have an opinion from the Rollbar team about that? Agree? Disagree?
(the exact link for the responsible code: https://github.com/rollbar/rollbar-php/blob/f6c7f9b7f45e346ebf3d0cc724964f114ba92b15/src/Monolog/Handler/RollbarHandler.php#L113 - the line was correct, it's just that master changed since then :slightly_smiling_face:)
I vote for this! It's not good to completely loose this information when issue passes to Rollbar. It this planned to be fixed?
This is related to #461 and has been resolved in the upcoming v4.0.0 release by #582.
In the update, we use the context $exception->getMessage() as the message and the $message as the description. The decision to do it this way was based on our most common use case where an exception or error is caught by Rollbar not explicitly logged by the user. In that instance $message is an exception, and no description will be included in the report sent to the Rollbar service.
I agree with everyone's comments. We don't want to lose the message. It is important. I would welcome feedback on making it the description.