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

Log->error($e) has different info than throw the exception and let error_reporting handle it #275

Closed
monteiro opened this issue Oct 26, 2017 · 4 comments
Assignees

Comments

@monteiro
Copy link

monteiro commented Oct 26, 2017

I'm currently using monolog and new relic handler:

Rollbar::init($rollbarConfiguration);
$logger->pushHandler(new PsrHandler(Rollbar::logger()));

When I try to log the exception using:

try {
 //something that throws an exception
} catch (\Exception $ex) {
  $this->logger->error($e);
}

The exception trace doesn't have any colors and it is different than letting rollbar error_reporting to handle the exceptions (without catching the exception).

If I throw the exception without catching it, the result is a more complete exception trace w/ colors.

It looks like when error_reporting catches the exception, it executes the DataBuilder to fill the log with more info.

@ArturMoczulski
Copy link
Contributor

Hey @monteiro

This is a result of using PsrHandler instead of RollbarHandler. Unfortunately, it is the best thing you can do as of right because RollbarHandler is heavily outdated and doesn't work with our latest releases.

I submitted a PR to Monolog repo long time ago with code changes to update RollbarHandler, but they still have not processed my PR. In meantime, I suggest you look into using this Mononolog PR: Seldaek/monolog#1042

More details on PsrHandler:
PsrHandler::handle on line 52 packs the Exception object into $record['message'] and converts it to a string

$this->logger->log(strtolower($record['level_name']), $record['message'], $record['context']);

This way the Exeception object is passed to RollbarLogger::log as a string and formatted in the JSON payload as a message instead of an Exception object.

@ArturMoczulski
Copy link
Contributor

ArturMoczulski commented Nov 1, 2017

Long story short this is the same issue as #249. I just posted yet comment requesting Monolog team an immediate action on this.

@mente
Copy link

mente commented Nov 2, 2017

Context exception is part of PSR-3 so why not add support of it directly into RollbarLogger rather than waiting for others to update their library?

@monteiro
Copy link
Author

monteiro commented Nov 2, 2017

Thanks @ArturMoczulski for the effort.

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

3 participants