Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect exception context in RollbarLogger #461

Closed
rieschl opened this issue Jun 3, 2019 · 1 comment
Closed

Respect exception context in RollbarLogger #461

rieschl opened this issue Jun 3, 2019 · 1 comment
Assignees
Milestone

Comments

@rieschl
Copy link

rieschl commented Jun 3, 2019

When using the PSR-3 LoggerInterface implementation \Rollbar\RollbarLogger directly in a class to log certain exceptions, Rollbar doesn't respect the exception array key in the context parameter, the exception has to be passed as message to see the pretty stack trace in the Rollbar web interface.

Although technically this is ok, because PSR-3 states that Every method accepts a string as the message, or an object with a __toString() method. and the Exception (and Throwable) class has a __toString() method, it would be nice to also be able to pass the exception via the $context['exception'] key and use a string as $message. PSR-3 defines that behavior explicitly.

So the following code snippets should log the same thing in Rollbar:

/**
 * @var \Psr\Log\LoggerInterface $logger
 * @var \Throwable $e
 */
$logger->error($e); // current
$logger->error($e->getMessage(), ['exception' => $e]); // suggested

Thanks :)

@danielmorell danielmorell added this to the v4.0.0 milestone Oct 25, 2022
@danielmorell danielmorell self-assigned this Oct 25, 2022
danielmorell added a commit that referenced this issue Dec 6, 2022
Fixed #461 Added support for psr/log context exception
@danielmorell
Copy link
Collaborator

This has been resolved and will be releases in the new v4.0.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants