Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-47332

Add debug only logging macro to facilitate printf style debugging

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.0
    • Affects Version/s: None
    • Component/s: Logging
    • None
    • Fully Compatible
    • Execution Team 2020-05-04

      When debugging or investigating a part of the system it is helpful to quickly add log messages for "printf" style debugging. The new LOGV2 macros make this much more unwieldy, since they require a log message id, and variable values can only be included in a message by adding attributes which is verbose. It would be nice to have a dedicated macro for printf debugging that provides the ability to print a string without providing a message id or any named attributes, since those are features are mostly relevant for production log messages and machine readability. They should not be necessary for local debugging. We could add a macro like logv2d() that behaves similarly to the old logging system. It would automatically use a default message id (since we have relaxed id checks in SERVER-46364) and provide an ability to use the stream operator to construct log messages e.g.

      logv2d() << "my log message, v1:" << 5 << ", v2: " << 6;
      

      Preferably this macro would be lowercase, to make it even more ergonomic when writing out printf style debugging messages quickly. We could also consider statically asserting that this macro is only allowed in debug builds, to make sure people don't use this macro to log messages in production.

            Assignee:
            henrik.edin@mongodb.com Henrik Edin
            Reporter:
            william.schultz@mongodb.com William Schultz (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: