Alexis Wilke
Alexis Wilke

Reputation: 20720

How do I send Bugsnag notifices to stderr?

I'm working on a Ruby software which may catch some errors (exceptions) and use Bugsnag to record the event in the Bugsnag logs.

For example, I may have something like this:

begin
  [...snip...]
rescue StandardError => e
  Bugsnag.notify(e)
end

What I'd like to be able to do is redirect the message logged by that line of code to my console. That way I could get it to my log file and then search on it and see what's before/after it and make sure things are working as expected.

Is there a way to setup Bugsnag to get such functionality?

Upvotes: 0

Views: 224

Answers (1)

rsokz
rsokz

Reputation: 174

I suggest using an On Error Callback. This callback will be executed for every handled and unhandled exception.

Bugsnag.configure do |config|
  config.add_on_error(proc do |event|
    # redirect message to your console here
    
  end)
end

Upvotes: 1

Related Questions