Class: Logfoo::Timed

Inherits:
Struct
  • Object
show all
Defined in:
lib/logfoo/timed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sourceObject

Returns the value of attribute source



1
2
3
# File 'lib/logfoo/timed.rb', line 1

def source
  @source
end

Instance Method Details

#benchmark(level, message, payload, block) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/logfoo/timed.rb', line 2

def benchmark(level, message, payload, block)
  payload    ||= {}
  time_start   = Time.now.to_f
  reply        = source._call_log_fn(block, payload)

  payload.merge!(duration: Time.now.to_f - time_start)
  source.public_send(level, message, payload)
  reply
end