Sha256: 40db3aa5952818aaadd24aa40b0b89c7ae1160eacd19d078b93fd4adb415bc89
Contents?: true
Size: 1.04 KB
Versions: 8
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literals: true module Lumberjack class Formatter # 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. class ExceptionFormatter attr_accessor :backtrace_cleaner def initialize(backtrace_cleaner = nil) self.backtrace_cleaner = backtrace_cleaner end 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 def clean_backtrace(trace) if trace && backtrace_cleaner backtrace_cleaner.call(trace) else trace end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems