Class: CheapAdvice::Trace::BaseFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cheap_advice/trace.rb

Direct Known Subclasses

DefaultFormatter, YamlFormatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, *args) ⇒ BaseFormatter

Returns a new instance of BaseFormatter.



115
116
117
# File 'lib/cheap_advice/trace.rb', line 115

def initialize logger, *args
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



113
114
115
# File 'lib/cheap_advice/trace.rb', line 113

def logger
  @logger
end

Instance Method Details

#format(obj, mode) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/cheap_advice/trace.rb', line 119

def format obj, mode
  case mode
  when :rcvr
    obj && obj.to_s
  when :module
    obj && obj.name
  when :time
    obj && obj.iso8601(6)
  when :error
    obj.inspect
  when :result
    obj.inspect
  when :method
    ad = ar.meth_to_s
  else
    nil
  end
end