Class: ClickHouse::Middleware::Logging
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- ClickHouse::Middleware::Logging
- Defined in:
- lib/click_house/middleware/logging.rb
Constant Summary collapse
- EMPTY =
''
- GET =
:get
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#starting ⇒ Object
readonly
Returns the value of attribute starting.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil, logger:) ⇒ Logging
constructor
A new instance of Logging.
-
#on_complete(env) ⇒ Object
rubocop:disable Layout/LineLength.
Constructor Details
#initialize(app = nil, logger:) ⇒ Logging
Returns a new instance of Logging.
13 14 15 16 |
# File 'lib/click_house/middleware/logging.rb', line 13 def initialize(app = nil, logger:) @logger = logger super(app) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
11 12 13 |
# File 'lib/click_house/middleware/logging.rb', line 11 def logger @logger end |
#starting ⇒ Object (readonly)
Returns the value of attribute starting.
11 12 13 |
# File 'lib/click_house/middleware/logging.rb', line 11 def starting @starting end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 |
# File 'lib/click_house/middleware/logging.rb', line 18 def call(env) @starting = super end |
#on_complete(env) ⇒ Object
rubocop:disable Layout/LineLength
24 25 26 27 28 29 |
# File 'lib/click_house/middleware/logging.rb', line 24 def on_complete(env) summary = SummaryMiddleware.extract(env) logger.info("\e[1m[35mSQL (#{duration_stats_log(summary)})\e[0m #{query(env)};") logger.debug(env.request_body) if log_body?(env) logger.info("\e[1m[36mRead: #{summary.read_rows} rows, #{summary.read_bytes_pretty}. Written: #{summary.written_rows} rows, #{summary.written_bytes_pretty}\e[0m") end |