Class: Mongo::Monitoring::CmapLogSubscriber

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/mongo/monitoring/cmap_log_subscriber.rb

Overview

Subscribes to CMAP events and logs them.

Since:

  • 2.9.0

Constant Summary

Constants included from Loggable

Loggable::PREFIX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger

Constructor Details

#initialize(options = {}) ⇒ CmapLogSubscriber

Create the new log subscriber.

Examples:

Create the log subscriber.

CmapLogSubscriber.new

Parameters:

  • options (Hash) (defaults to: {})

    The options.

Options Hash (options):

  • :logger (Logger)

    An optional custom logger.

Since:

  • 2.9.0



42
43
44
# File 'lib/mongo/monitoring/cmap_log_subscriber.rb', line 42

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsHash (readonly)

Returns options The options.

Returns:

  • (Hash)

    options The options.

Since:

  • 2.9.0



30
31
32
# File 'lib/mongo/monitoring/cmap_log_subscriber.rb', line 30

def options
  @options
end

Instance Method Details

#published(event) ⇒ Object

Handle a CMAP event.

Parameters:

  • event (Event)

    The event.

Since:

  • 2.9.0



51
52
53
# File 'lib/mongo/monitoring/cmap_log_subscriber.rb', line 51

def published(event)
  log_debug("EVENT: #{event.summary}") if logger.debug?
end