Class: ElasticRecord::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- ElasticRecord::LogSubscriber
- Defined in:
- lib/elastic_record/log_subscriber.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reset_runtime ⇒ Object
11 12 13 14 |
# File 'lib/elastic_record/log_subscriber.rb', line 11 def self.reset_runtime rt, self.runtime = runtime, 0 rt end |
.runtime ⇒ Object
7 8 9 |
# File 'lib/elastic_record/log_subscriber.rb', line 7 def self.runtime Thread.current["elastic_record_request_runtime"] ||= 0 end |
.runtime=(value) ⇒ Object
3 4 5 |
# File 'lib/elastic_record/log_subscriber.rb', line 3 def self.runtime=(value) Thread.current["elastic_record_request_runtime"] = value end |
Instance Method Details
#request(event) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/elastic_record/log_subscriber.rb', line 16 def request(event) self.class.runtime += event.duration payload = event.payload request_log = "#{payload[:request].method} #{payload[:http].address}:#{payload[:http].port}#{payload[:request].path}" if payload[:request].body request_log << " '#{payload[:request].body}'" end debug "(#{event.duration.round(1)}ms) #{request_log}" end |