-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
Fully Compatible
-
QE 2024-12-09, QE 2024-12-23
All other LOGV2 macros have a way to pass an Options. LOGV2_PROD_ONLY does not.
There should be a way to get the effective "prod only" verbosity, so that it can be used in ways that are unanticipated by the log.h header (for example, to pass it as a parameter or store it in a variable.
This should probably be a feature of the LogSeverity class, like the other LogSeverity value-yielding functions. Suggestion for logv2/log_severity.h, inside class LogSeverity:
static LogSeverity ProdOnly() { return getTestCommandsEnabled() ? LogSeverity::Debug(1) : LogSeverity::Log(); }
Then you can use it more naturally in the various idioms that use LogSeverity in the codebase. Embedding this severity decision inside the LOGV2_PROD_ONLY as we've done currently doesn't enable that kind of thing.
Factoring out a ProdOnly() accessor also simplifies the body of LOGV2_PROD_ONLY, making it look more like all of the other LOGV2 macros that select a severity.
#define LOGV2_PROD_ONLY(ID, MSG, ...) \ LOGV2_IMPL(ID, ::mongo::logv2::LogSeverity::ProdOnly(), \ ::mongo::logv2::LogOptions{MONGO_LOGV2_DEFAULT_COMPONENT}, MSG, \ ##__VA_ARGS__) #define LOGV2_PROD_ONLY_OPTIONS(ID, OPTIONS, MSG, ...) \ LOGV2_IMPL(ID, ::mongo::logv2::LogSeverity::ProdOnly(), \ ::mongo::logv2::LogOptions::ensureValidComponent( \ OPTIONS, MONGO_LOGV2_DEFAULT_COMPONENT), \ MSG, ##__VA_ARGS__)
The idea is to refactor so that there's a LogSeverity::ProdOnly() accessor that returns a LogSeverity. Calls to logv2::LogSeverity::ProdOnly() can be used in most of the same situations that logv2::LogSeverify::Info() or logv2::LogSeverity::Log() etc would be used.
- is caused by
-
SERVER-97082 Create prod level zero/testing debug-1 log macro
- Closed