Class: BoltRb::Middleware::Logging

Inherits:
Base
  • Object
show all
Defined in:
lib/bolt_rb/middleware/logging.rb

Overview

Logging middleware for request/response logging

Logs the event type being processed and the time taken to process it. This is useful for debugging and monitoring your Bolt application.

Examples:

Output

[BoltRb] Processing event:message
[BoltRb] Completed event:message in 12.34ms

Instance Method Summary collapse

Instance Method Details

#call(context) { ... } ⇒ void

This method returns an undefined value.

Processes the request with logging

Logs the event type before processing and the elapsed time after.

Parameters:

Yields:

  • Continues to the next middleware in the chain



21
22
23
24
25
26
27
28
29
30
# File 'lib/bolt_rb/middleware/logging.rb', line 21

def call(context)
  event_type = determine_event_type(context.payload)
  BoltRb.logger.info "[BoltRb] Processing #{event_type}"
  started = Time.now

  yield if block_given?

  elapsed = ((Time.now - started) * 1000).round(2)
  BoltRb.logger.info "[BoltRb] Completed #{event_type} in #{elapsed}ms"
end