Class: Lumberjack::Formatter::ExceptionFormatter
- Inherits:
-
Object
- Object
- Lumberjack::Formatter::ExceptionFormatter
- Defined in:
- lib/lumberjack/formatter/exception_formatter.rb
Overview
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.
Instance Attribute Summary collapse
-
#backtrace_cleaner ⇒ Object
Returns the value of attribute backtrace_cleaner.
Instance Method Summary collapse
- #call(exception) ⇒ Object
-
#initialize(backtrace_cleaner = nil) ⇒ ExceptionFormatter
constructor
A new instance of ExceptionFormatter.
Constructor Details
#initialize(backtrace_cleaner = nil) ⇒ ExceptionFormatter
Returns a new instance of ExceptionFormatter.
14 15 16 |
# File 'lib/lumberjack/formatter/exception_formatter.rb', line 14 def initialize(backtrace_cleaner = nil) self.backtrace_cleaner = backtrace_cleaner end |
Instance Attribute Details
#backtrace_cleaner ⇒ Object
Returns the value of attribute backtrace_cleaner.
10 11 12 |
# File 'lib/lumberjack/formatter/exception_formatter.rb', line 10 def backtrace_cleaner @backtrace_cleaner end |
Instance Method Details
#call(exception) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/lumberjack/formatter/exception_formatter.rb', line 18 def call(exception) = +"#{exception.class.name}: #{exception.}" trace = exception.backtrace if trace trace = clean_backtrace(trace) << "#{Lumberjack::LINE_SEPARATOR} #{trace.join("#{Lumberjack::LINE_SEPARATOR} ")}" end end |