@@ -41,7 +41,10 @@ logging subscriber used internally by the driver:
4141 include Mongo::Loggable
4242
4343 def started(event)
44- log_debug("#{prefix(event)} | STARTED | #{format_command(event.command)}")
44+ # The default inspection of a command which is a BSON document gets
45+ # truncated in the middle. To get the full rendering of the command, the
46+ # ``to_json`` method can be called on the document.
47+ log_debug("#{prefix(event)} | STARTED | #{format_command(event.command.to_json)}")
4548 end
4649
4750 def succeeded(event)
@@ -137,35 +140,35 @@ can look like the following:
137140 format("SDAM | %s".freeze, message)
138141 end
139142 end
140-
143+
141144 class TopologyOpeningLogSubscriber < SDAMLogSubscriber
142145 private
143-
146+
144147 def format_event(event)
145148 "Topology type '#{event.topology.display_name}' initializing."
146149 end
147150 end
148-
151+
149152 class ServerOpeningLogSubscriber < SDAMLogSubscriber
150153 private
151-
154+
152155 def format_event(event)
153156 "Server #{event.address} initializing."
154157 end
155158 end
156-
159+
157160 class ServerDescriptionChangedLogSubscriber < SDAMLogSubscriber
158161 private
159-
162+
160163 def format_event(event)
161164 "Server description for #{event.address} changed from " +
162165 "'#{event.previous_description.server_type}' to '#{event.new_description.server_type}'."
163166 end
164167 end
165-
168+
166169 class TopologyChangedLogSubscriber < SDAMLogSubscriber
167170 private
168-
171+
169172 def format_event(event)
170173 if event.previous_topology != event.new_topology
171174 "Topology type '#{event.previous_topology.display_name}' changed to " +
@@ -176,18 +179,18 @@ can look like the following:
176179 end
177180 end
178181 end
179-
182+
180183 class ServerClosedLogSubscriber < SDAMLogSubscriber
181184 private
182-
185+
183186 def format_event(event)
184187 "Server #{event.address} connection closed."
185188 end
186189 end
187-
190+
188191 class TopologyClosedLogSubscriber < SDAMLogSubscriber
189192 private
190-
193+
191194 def format_event(event)
192195 "Topology type '#{event.topology.display_name}' closed."
193196 end
@@ -228,7 +231,7 @@ since the events may be published during the client's construction:
228231 topology_changed_subscriber = TopologyChangedLogSubscriber.new
229232 server_closed_subscriber = ServerClosedLogSubscriber.new
230233 topology_closed_subscriber = TopologyClosedLogSubscriber.new
231-
234+
232235 sdam_proc = Proc.new do |client|
233236 client.subscribe(Mongo::Monitoring::TOPOLOGY_OPENING,
234237 topology_opening_subscriber)
@@ -316,9 +319,9 @@ The following is an example logging heartbeat event subscriber:
316319 def failed(event)
317320 log_debug("#{event.address} | FAILED | #{event.error.class}: #{event.error.message} | #{event.duration}s")
318321 end
319-
322+
320323 private
321-
324+
322325 def logger
323326 Mongo::Logger.logger
324327 end
0 commit comments