Skip to content

Commit 8005ba5

Browse files
committed
CDRIVER-794: document mongoc_log_trace_enable / disable
Also touch on CDRIVER-503 by noting how to disable all logging
1 parent 346349d commit 8005ba5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/logging.page

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ void mongoc_log_default_handler (mongoc_log_level_t log_level,
6262
MONGOC_WARNING ("An error occurred: %s", strerror (errno));]]></code></screen>
6363
</section>
6464

65+
<section id="tracing">
66+
<title>Tracing</title>
67+
<p>If compiling your own copy of the MongoDB C driver, consider configuring with <code>--enable-tracing</code> to enable function tracing and hex dumps of network packets to <code>STDERR</code> and <code>STDOUT</code> during development and debugging.</p>
68+
<p>This is especially useful when debugging what may be going on internally in the driver.</p>
69+
<p>Trace messages can be enabled and disabled by calling <code>mongoc_log_trace_enable()</code> and <code>mongoc_log_trace_disable()</code></p>
70+
<note type="warning"><p>
71+
Compiling the driver with <code>--enable-tracing</code> will affect its performance. Disabling tracing with <code>mongoc_log_trace_disable()</code> significantly reduces the overhead, but cannot remove it completely.
72+
</p></note>
73+
74+
</section>
75+
6576
<section id="handlers">
6677
<title>Custom Log Handlers</title>
6778
<p>The default log handler prints a timestamp and the log message to <code>stdout</code>, or to <code>stderr</code> for warnings, critical messages, and errors.
@@ -71,4 +82,10 @@ MONGOC_WARNING ("An error occurred: %s", strerror (errno));]]></code></screen>
7182
<screen><code mime="text/x-csrc"><![CDATA[mongoc_log_set_handler (mongoc_log_default_handler, NULL);]]></code></screen>
7283
</section>
7384

85+
<section id="disable-logs">
86+
<title>Disable logging</title>
87+
<p>To disable all logging, including warnings, critical messages and errors, you need to provide an empty log handler</p>
88+
<screen><code mime="text/x-csrc"><![CDATA[mongoc_log_set_handler (NULL, NULL);]]></code></screen>
89+
</section>
90+
7491
</page>

0 commit comments

Comments
 (0)