Class: Elastictastic::Middleware::LogRequests
- Defined in:
- lib/elastictastic/middleware.rb
Instance Method Summary collapse
-
#initialize(connection, logger) ⇒ LogRequests
constructor
A new instance of LogRequests.
- #request(method, path, body = nil) ⇒ Object
Methods included from TransportMethods
#delete, #get, #head, #post, #put
Constructor Details
#initialize(connection, logger) ⇒ LogRequests
Returns a new instance of LogRequests.
82 83 84 85 |
# File 'lib/elastictastic/middleware.rb', line 82 def initialize(connection, logger) super(connection) @logger = logger end |
Instance Method Details
#request(method, path, body = nil) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/elastictastic/middleware.rb', line 87 def request(method, path, body = nil) now = Time.now super.tap do @logger.debug do time = ((Time.now - now) * 1000).to_i = "ElasticSearch #{method.to_s.upcase} (#{time}ms) #{path}" << ' ' << body if body end end end |