Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4800

Return early in mongoc_log_trace functions if no logger is configured

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.28.0
    • Affects Version/s: None
    • Component/s: Logging
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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;
      }
      

            Assignee:
            josh.siegel@mongodb.com Josh Siegel
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: