Skip to content

Commit

Permalink
Fix filtered levels.
Browse files Browse the repository at this point in the history
After new interface changes we lost this feature :-/. This PRs re-enables it.

BTW, ignore exceptions should be still working before this PR.
  • Loading branch information
Jon de Andres committed Oct 30, 2014
1 parent 4d580c5 commit 415e37a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/rollbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ def log(level, *args)

return 'ignored' if ignored?(exception)

exception_level = filtered_level(exception)
level = exception_level if exception_level

begin
report(level, message, exception, extra)
rescue Exception => e
Expand Down Expand Up @@ -191,6 +194,8 @@ def ignored?(exception)
end

def filtered_level(exception)
return unless exception

filter = configuration.exception_level_filters[exception.class.name]
if filter.respond_to?(:call)
filter.call(exception)
Expand Down
9 changes: 9 additions & 0 deletions spec/rollbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,15 @@
Rollbar.error(exception)
end

it 'sends the correct filtered level' do
Rollbar.configure do |config|
config.exception_level_filters = { 'NameError' => 'warning' }
end

Rollbar.error(exception)
expect(Rollbar.last_report[:level]).to be_eql('warning')
end

it "should work with an IO object as rack.errors" do
logger_mock.should_receive(:info).with('[Rollbar] Success')

Expand Down

0 comments on commit 415e37a

Please sign in to comment.