Skip to content

Commit

Permalink
Merge pull request #160 from rollbar/fix-filtered-levels
Browse files Browse the repository at this point in the history
Fix filtered levels.
  • Loading branch information
brianr committed Oct 31, 2014
2 parents aba35da + 415e37a commit 44535b9
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 44535b9

Please sign in to comment.