Class: CheapAdvice::Trace::YamlFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- CheapAdvice::Trace::YamlFormatter
- Defined in:
- lib/cheap_advice/trace.rb
Overview
class
Instance Attribute Summary
Attributes inherited from BaseFormatter
Instance Method Summary collapse
Methods inherited from BaseFormatter
Constructor Details
This class inherits a constructor from CheapAdvice::Trace::BaseFormatter
Instance Method Details
#record(ar, mode) ⇒ Object
217 218 219 220 221 222 223 224 225 |
# File 'lib/cheap_advice/trace.rb', line 217 def record ar, mode case mode when :after data = to_hash(ar, mode) YAML.dump(data) else nil end end |
#to_hash(ar, mode) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/cheap_advice/trace.rb', line 192 def to_hash ar, mode ad = ar.advised data = (ar.advice[:log_data] || EMPTY_Hash).dup data.update(ar.advised[:log_data] || EMPTY_Hash) # pp [ :'ar.data=', ar.data ] data.update(ar.data) # pp [ :'data=', data ] if x = ad.log_prefix(logger, ar) data[:log_prefix] = x end data[:meth] = ar.meth data[:mod] = Module === (x = ar.mod) ? x.name : x data[:kind] = ar.kind data[:signature] = ar.meth_to_s data[:rcvr] = format(ar.rcvr, :rcvr) if ad[:log_rcvr] data[:rcvr_class] = ar.rcvr.class.name if x = data[:time_after] && data[:time_before] && (data[:time_after].to_f - data[:time_before].to_f) data[:time_elapsed] = x end data end |