newrelic: refactor error logging.
* Factor out New Relic logging to DanbooruLogger class. * Log all exceptions to New Relic, not just statement timeouts.
This commit is contained in:
12
app/logical/danbooru_logger.rb
Normal file
12
app/logical/danbooru_logger.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
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
|
||||
Reference in New Issue
Block a user