Class: ClickHouse::Middleware::Logging

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/click_house/middleware/logging.rb

Constant Summary collapse

SUMMARY_HEADER =
'x-clickhouse-summary'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app = nil, logger:) ⇒ Logging

Returns a new instance of Logging.


12
13
14
15
# File 'lib/click_house/middleware/logging.rb', line 12

def initialize(app = nil, logger:)
  @logger = logger
  super(app)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body


10
11
12
# File 'lib/click_house/middleware/logging.rb', line 10

def body
  @body
end

#loggerObject (readonly)

Returns the value of attribute logger


10
11
12
# File 'lib/click_house/middleware/logging.rb', line 10

def logger
  @logger
end

#startingObject (readonly)

Returns the value of attribute starting


10
11
12
# File 'lib/click_house/middleware/logging.rb', line 10

def starting
  @starting
end

Instance Method Details

#call(environment) ⇒ Object


17
18
19
20
21
# File 'lib/click_house/middleware/logging.rb', line 17

def call(environment)
  @starting = timestamp
  @body = environment.body if log_body?
  @app.call(environment).on_complete(&method(:on_complete))
end