123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Monitoring::UnifiedSdamLogSubscriber

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/mongo/monitoring/unified_sdam_log_subscriber.rb

Overview

Subscribes to SDAM events and logs them.

Since:

  • 2.11.0

Constant Summary

::Mongo::Loggable - Included

PREFIX

Class Method Summary

Instance Attribute Summary

Instance Method Summary

::Mongo::Loggable - Included

#log_debug

Convenience method to log debug messages with the standard prefix.

#log_error

Convenience method to log error messages with the standard prefix.

#log_fatal

Convenience method to log fatal messages with the standard prefix.

#log_info

Convenience method to log info messages with the standard prefix.

#log_warn

Convenience method to log warn messages with the standard prefix.

#logger

Get the logger instance.

#_mongo_log_prefix, #format_message

Constructor Details

.new(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

[ GitHub ]

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

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

Instance Attribute Details

#optionsHash (readonly)

Returns:

  • (Hash)

    options The options.

Since:

  • 2.11.0

[ GitHub ]

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

attr_reader :options

Instance Method Details

#published(event) Also known as: #succeeded

Handle an event.

Parameters:

  • event (Event)

    The event.

Since:

  • 2.11.0

[ GitHub ]

  
# 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)

Since:

  • 2.11.0

[ GitHub ]

  
# 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

#succeeded(event)

Alias for #published.

[ GitHub ]

  
# File 'lib/mongo/monitoring/unified_sdam_log_subscriber.rb', line 53

alias :succeeded :published