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

Report ActiveSupport::LogSubscriber errors to Rails.error #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions activesupport/lib/active_support/log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def mode_from(options)
end

def log_exception(name, e)
ActiveSupport.error_reporter.report(e, source: name)

if logger
logger.error "Could not log #{name.inspect} event. #{e.class}: #{e.message} #{e.backtrace}"
end
Expand Down
10 changes: 6 additions & 4 deletions activesupport/test/log_subscriber_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ def test_flushes_the_same_logger_just_once
end

def test_logging_does_not_die_on_failures
ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
instrument "puke.my_log_subscriber"
instrument "some_event.my_log_subscriber"
wait
assert_error_reported do
ActiveSupport::LogSubscriber.attach_to :my_log_subscriber, @log_subscriber
instrument "puke.my_log_subscriber"
instrument "some_event.my_log_subscriber"
wait
end

assert_equal 1, @logger.logged(:info).size
assert_equal "some_event.my_log_subscriber", @logger.logged(:info).last
Expand Down