Class: RestApi::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- RestApi::LogSubscriber
- Defined in:
- app/models/rest_api/log_subscriber.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reset_runtime ⇒ Object
9 10 11 12 |
# File 'app/models/rest_api/log_subscriber.rb', line 9 def self.reset_runtime rt, self.runtime = runtime, 0 rt end |
.runtime ⇒ Object
6 7 8 |
# File 'app/models/rest_api/log_subscriber.rb', line 6 def self.runtime Thread.current["rest_api_call_runtime"] ||= 0 end |
.runtime=(value) ⇒ Object
3 4 5 |
# File 'app/models/rest_api/log_subscriber.rb', line 3 def self.runtime=(value) Thread.current["rest_api_call_runtime"] = value end |
Instance Method Details
#request(event) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/rest_api/log_subscriber.rb', line 14 def request(event) self.class.runtime += event.duration return unless logger.debug? name = '%s (%.1fms)' % ['OpenShift API', event.duration] call = "#{color(event.payload.delete(:method), BOLD, true)} #{event.payload.delete(:request_uri)}" result = event.payload[:result] query = {:code => result.code}.map{ |k,v| "#{k}: #{color(v, BOLD, true)}" }.join(', ') if result debug " #{color(name, BLUE, true)} #{call} [ #{query} ]" end |