Simple error recipient for centralizing error logging in an app.
No more of those pesky NewRelic::Agent.notice_error everywhere, only Flub.register_exception
Add this line to your application's Gemfile:
gem 'flub'
And then execute:
$ bundle
Or install it yourself as:
$ gem install flub
# config/initializers/flub.rb
logger Rails.logger # optional, default is a NullLogger
Flub.configure do
on_error do |e, data, log_level|
Rollbar.report_exception(e, nil, data, log_level)
end
on_error do |e, data, log_level|
NewRelic::Agent.notice_error(e, custom_params: data)
end
end
# somewhere else
Flub.register_exception(ActiveRecord::RecordNotFound.new, {current_user: 123}, :warn)
This will notify both Rollbar and New Relic about the error.
Each block provided to on_error
is executed in it's own begin/rescue, logging any failures to the provided logger.
- Fork it ( http://github.com//flub/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request