class RemoteResource::LogSubscriber
Public Instance Methods
find(event)
click to toggle source
# File lib/remote_resource/log_subscriber.rb, line 9 def find(event) log_action('Find', event) end
http_get(event)
click to toggle source
# File lib/remote_resource/log_subscriber.rb, line 17 def http_get(event) log_action('HTTP GET', event) { |payload| payload[:attribute] } end
log_action(action, event, &block)
click to toggle source
the optional block acts as a filter for the log description. The block is passed the payload and its return value is used as the log description. The whole payload is used as the description if the block is omitted.
# File lib/remote_resource/log_subscriber.rb, line 24 def log_action(action, event, &block) payload = event.payload description = block ? block.call(payload) : payload if (attribute = payload[:attribute]) subject = attribute[:location] action = "#{subject} #{action} (#{event.duration.round(2)}ms)" end action = color(action, GREEN, true) debug("#{action} #{description}") end
logger()
click to toggle source
# File lib/remote_resource/log_subscriber.rb, line 5 def logger RemoteResource.logger end
storage_lookup(event)
click to toggle source
# File lib/remote_resource/log_subscriber.rb, line 13 def storage_lookup(event) log_action('Storage lookup', event) { |payload| payload[:attribute] } end