Files
danbooru/app/logical/danbooru_logger.rb
evazion 9a6add9730 newrelic: refactor error logging.
* Factor out New Relic logging to DanbooruLogger class.
* Log all exceptions to New Relic, not just statement timeouts.
2019-08-08 22:16:39 -05:00

13 lines
400 B
Ruby

class DanbooruLogger
def self.log(exception, expected: false, **params)
if !expected
backtrace = Rails.backtrace_cleaner.clean(exception.backtrace).join("\n")
Rails.logger.error("#{exception.class}: #{exception.message}\n#{backtrace}")
end
if defined?(::NewRelic)
::NewRelic::Agent.notice_error(exception, expected: expected, custom_params: params)
end
end
end