[CDRIVER-4800] Return early in mongoc_log_trace functions if no logger is configured Created: 20/Dec/23  Updated: 08/Jan/24

Status: Backlog
Project: C Driver
Component/s: Logging
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to PHPC-2337 Performance degradation in 1.17 due t... Closed
is related to CDRIVER-4697 More efficient trace toggle Backlog

 Description   

PHPC-2337 fixed an issue where I inadvertently forgot to explicitly disable tracing at runtime (PHPC compiles with tracing enabled, so that was the default), despite clearing libmongoc's log handler. This introduced a performance regression whereby trace log messages were still generated, but never written.

A possible improvement in libmongoc would have mongoc_log_trace_iovec() and mongoc_log_trace_bytes() return early if a log handler isn't registered (beyond just checking whether tracing is enabled). mongoc_log() already does this itself for its stop_logging calculation.

One approach may be to turn the following snippet from mongoc_log() into a macro to call from all three functions:

stop_logging = !gLogFunc;
stop_logging = stop_logging || (log_level == MONGOC_LOG_LEVEL_TRACE &&
                                !_mongoc_log_trace_is_enabled ());
if (stop_logging) {
   return;
}


Generated at Wed Feb 07 21:21:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.