class Lumberjack::Formatter::ExceptionFormatter
Format an exception including the backtrace. You can specify an object that responds to `call` as a backtrace cleaner. The exception backtrace will be passed to this object and the returned array is what will be logged. You can use this to clean out superfluous lines.
Attributes
backtrace_cleaner[RW]
Public Class Methods
new(backtrace_cleaner = nil)
click to toggle source
# File lib/lumberjack/formatter/exception_formatter.rb, line 12 def initialize(backtrace_cleaner = nil) self.backtrace_cleaner = backtrace_cleaner end
Public Instance Methods
call(exception)
click to toggle source
# File lib/lumberjack/formatter/exception_formatter.rb, line 16 def call(exception) message = "#{exception.class.name}: #{exception.message}" trace = exception.backtrace if trace trace = clean_backtrace(trace) message << "#{Lumberjack::LINE_SEPARATOR} #{trace.join("#{Lumberjack::LINE_SEPARATOR} ")}" end message end
Private Instance Methods
clean_backtrace(trace)
click to toggle source
# File lib/lumberjack/formatter/exception_formatter.rb, line 28 def clean_backtrace(trace) if trace && backtrace_cleaner backtrace_cleaner.call(trace) else trace end end