Class: Mongo::Monitoring::CommandLogSubscriber
- Inherits:
-
Object
- Object
- Mongo::Monitoring::CommandLogSubscriber
- Includes:
- Loggable
- Defined in:
- lib/mongo/monitoring/command_log_subscriber.rb
Overview
Subscribes to command events and logs them.
Constant Summary collapse
- LOG_STRING_LIMIT =
Constant for the max number of characters to print when inspecting a query field.
250
Constants included from Loggable
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Options The options.
Instance Method Summary collapse
-
#failed(event) ⇒ Object
Handle the command failed event.
-
#initialize(options = {}) ⇒ CommandLogSubscriber
constructor
Create the new log subscriber.
-
#started(event) ⇒ Object
Handle the command started event.
-
#succeeded(event) ⇒ Object
Handle the command succeeded event.
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Constructor Details
#initialize(options = {}) ⇒ CommandLogSubscriber
Create the new log subscriber.
43 44 45 |
# File 'lib/mongo/monitoring/command_log_subscriber.rb', line 43 def initialize( = {}) = end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns options The options.
25 26 27 |
# File 'lib/mongo/monitoring/command_log_subscriber.rb', line 25 def end |
Instance Method Details
#failed(event) ⇒ Object
Handle the command failed event.
88 89 90 91 92 |
# File 'lib/mongo/monitoring/command_log_subscriber.rb', line 88 def failed(event) if logger.debug? log_debug("#{prefix(event)} | FAILED | #{event.message} | #{event.duration}s") end end |
#started(event) ⇒ Object
Handle the command started event.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/mongo/monitoring/command_log_subscriber.rb', line 55 def started(event) if logger.debug? _prefix = prefix(event, connection_generation: event.connection_generation, connection_id: event.connection_id, server_connection_id: event.server_connection_id, ) log_debug("#{_prefix} | STARTED | #{format_command(event.command)}") end end |
#succeeded(event) ⇒ Object
Handle the command succeeded event.
74 75 76 77 78 |
# File 'lib/mongo/monitoring/command_log_subscriber.rb', line 74 def succeeded(event) if logger.debug? log_debug("#{prefix(event)} | SUCCEEDED | #{'%.3f' % event.duration}s") end end |