class Bixby::Log::FilteringLayout
Public Instance Methods
filter_ex(ex)
click to toggle source
Filter the exception if a block is available
@param [Exception] ex
@return [Array<String>] backtrace
# File lib/bixby-common/util/log/filtering_layout.rb, line 14 def filter_ex(ex) if @filter.nil? then return ex.backtrace end return @filter.call(ex) end
format_obj( obj )
click to toggle source
Return a string representation of the given object. Depending upon the configuration of the logger system the format will be an inspect
based representation or a yaml
based representation.
@param [Object] obj
@return [String]
# File lib/bixby-common/util/log/filtering_layout.rb, line 37 def format_obj( obj ) case obj when String; obj when Exception str = "<#{obj.class.name}> #{obj.message}" if @backtrace && !obj.backtrace.nil? str << "\n\t" << filter_ex(obj).join("\n\t") end str when nil; "<#{obj.class.name}> nil" else str = "<#{obj.class.name}> " str << case @obj_format when :inspect; obj.inspect when :yaml; try_yaml(obj) when :json; try_json(obj) else obj.to_s end str end end
set_filter(&block)
click to toggle source
Set the exception filter
@param [Block] block @yield [Exception] the exception to filter
# File lib/bixby-common/util/log/filtering_layout.rb, line 26 def set_filter(&block) @filter = block end