Permalink
Browse files

Add logging to added/removed events

  • Loading branch information...
durran committed Feb 23, 2014
1 parent fcf075f commit 38d09742413cc6871c8e169ce698989117b9730b
Showing with 23 additions and 3 deletions.
  1. +1 −1 lib/mongo.rb
  2. +11 −1 lib/mongo/event/host_added.rb
  3. +11 −1 lib/mongo/event/host_removed.rb
View
@@ -4,9 +4,9 @@
require 'mongo/cluster'
require 'mongo/collection'
require 'mongo/database'
-require 'mongo/event'
require 'mongo/loggable'
require 'mongo/logger'
+require 'mongo/event'
require 'mongo/pool'
require 'mongo/protocol'
require 'mongo/scope'
@@ -19,6 +19,7 @@ module Event
#
# @since 3.0.0
class HostAdded
+ include Loggable
# @return [ Mongo::Server ] server The event publisher.
attr_reader :server
@@ -35,8 +36,17 @@ def initialize(server)
@server = server
end
+ # This event publishes an event to add the server and logs the
+ # configuration change.
+ #
+ # @example Handle the event.
+ # host_added.handle('127.0.0.1:27018')
+ #
+ # @param [ String ] address The added host.
+ #
+ # @since 3.0.0
def handle(address)
- # @todo: Log the description change here.
+ log(:debug, 'MONGODB', [ "#{address} added to replica set configuration." ])
server.publish(Event::SERVER_ADDED, address)
end
end
@@ -19,6 +19,7 @@ module Event
#
# @since 3.0.0
class HostRemoved
+ include Loggable
# @return [ Mongo::Server ] server The event publisher.
attr_reader :server
@@ -35,8 +36,17 @@ def initialize(server)
@server = server
end
+ # This event publishes an event to remove the server and logs the
+ # configuration change.
+ #
+ # @example Handle the event.
+ # host_removed.handle('127.0.0.1:27018')
+ #
+ # @param [ String ] address The removed host.
+ #
+ # @since 3.0.0
def handle(address)
- # @todo: Log the description change here.
+ log(:debug, 'MONGODB', [ "#{address} removed from replica set configuration." ])
server.publish(Event::SERVER_REMOVED, address)
end
end

0 comments on commit 38d0974

Please sign in to comment.