Class: Mongo::Monitoring::UnifiedSdamLogSubscriber

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

Overview

Subscribes to SDAM events and logs them.

Since:

  • 2.11.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 = {}) ⇒ UnifiedSdamLogSubscriber

Create the new log subscriber.

Parameters:

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

    The options.

Options Hash (options):

  • :logger (Logger)

    An optional custom logger.

Since:

  • 2.11.0



40
41
42
# File 'lib/mongo/monitoring/unified_sdam_log_subscriber.rb', line 40

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

Instance Attribute Details

#optionsHash (readonly)

Returns options The options.

Returns:

  • (Hash)

    options The options.

Since:

  • 2.11.0



31
32
33
# File 'lib/mongo/monitoring/unified_sdam_log_subscriber.rb', line 31

def options
  @options
end

Instance Method Details

#published(event) ⇒ Object Also known as: succeeded

Handle an event.

Parameters:

  • event (Event)

    The event.

Since:

  • 2.11.0



49
50
51
# File 'lib/mongo/monitoring/unified_sdam_log_subscriber.rb', line 49

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

#subscribe(client) ⇒ Object

Since:

  • 2.11.0



55
56
57
58
59
60
61
62
# File 'lib/mongo/monitoring/unified_sdam_log_subscriber.rb', line 55

def subscribe(client)
  client.subscribe(Mongo::Monitoring::TOPOLOGY_OPENING, self)
  client.subscribe(Mongo::Monitoring::SERVER_OPENING, self)
  client.subscribe(Mongo::Monitoring::SERVER_DESCRIPTION_CHANGED, self)
  client.subscribe(Mongo::Monitoring::TOPOLOGY_CHANGED, self)
  client.subscribe(Mongo::Monitoring::SERVER_CLOSED, self)
  client.subscribe(Mongo::Monitoring::TOPOLOGY_CLOSED, self)
end