Class: Bixby::Log::FilteringLayout
- Inherits:
-
Logging::Layouts::Pattern
- Object
- Logging::Layouts::Pattern
- Bixby::Log::FilteringLayout
- Defined in:
- lib/bixby-common/util/log/filtering_layout.rb
Instance Method Summary collapse
-
#filter_ex(ex) ⇒ Array<String>
Filter the exception if a block is available.
-
#format_obj(obj) ⇒ String
Return a string representation of the given object.
-
#set_filter(&block) {|Exception| ... } ⇒ Object
Set the exception filter.
Instance Method Details
#filter_ex(ex) ⇒ Array<String>
Filter the exception if a block is available
14 15 16 17 18 19 20 |
# 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) ⇒ String
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.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# 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.}" 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) {|Exception| ... } ⇒ Object
Set the exception filter
26 27 28 |
# File 'lib/bixby-common/util/log/filtering_layout.rb', line 26 def set_filter(&block) @filter = block end |