Sha256: f00cf6cebd88a185068f9736367d2671b0e338103b977cdeb4770392638691a3
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
module Timber module Probes class ActionDispatchDebugExceptions < Probe module InstanceMethods def self.included(klass) klass.class_eval do private # We have to monkey patch because ruby < 2.0 does not support prepend. alias_method :_timber_old_log_error, :log_error def log_error(*args) # Rails 3.0 has 1 arg, >= 3.1 uses 2 args, the last being an exception wrapper exception = args.size == 1 ? args.first : args.last.exception # AR only logs queries if debugging, no need to do anything otherwise context = Contexts::Exception.new(exception) CurrentContext.add(context) do _timber_old_log_error(*args) end end end end end attr_reader :target_class def initialize load_debug_exceptions rescue RequirementNotMetError load_show_exceptions end def insert! return true if target_class.include?(InstanceMethods) target_class.send(:include, InstanceMethods) end private # Rails >= 3.1 logs the error here def load_debug_exceptions require "action_dispatch/middleware/debug_exceptions" @target_class = ::ActionDispatch::DebugExceptions true rescue LoadError => e raise RequirementNotMetError.new(e.message) end # Rails 3.0 logs the error here def load_show_exceptions require "action_dispatch/middleware/show_exceptions" @target_class = ::ActionDispatch::ShowExceptions true rescue LoadError => e raise RequirementNotMetError.new(e.message) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timberio-1.0.0.beta1 | lib/timber/probes/action_dispatch_debug_exceptions.rb |