summaryrefslogtreecommitdiff
path: root/src/mongo/logv2/log_options.h
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-01-22 12:36:22 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-01-27 16:47:55 +0000
commit57ea9cdff8f21b968dba358bbb1b814e0aa366f7 (patch)
tree77f08e152d20b4eb8a6390eb2287da807f8b3658 /src/mongo/logv2/log_options.h
parentd31d143cee82e9d8588462f2d8d0ec1b81a49fdf (diff)
downloadmongo-57ea9cdff8f21b968dba358bbb1b814e0aa366f7.tar.gz
SERVER-45705 Fix ODR violation in LogOptions where logv2 component could be wrong depending on linkage.
Diffstat (limited to 'src/mongo/logv2/log_options.h')
-rw-r--r--src/mongo/logv2/log_options.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/logv2/log_options.h b/src/mongo/logv2/log_options.h
index 481c98db403..baf3faafd5c 100644
--- a/src/mongo/logv2/log_options.h
+++ b/src/mongo/logv2/log_options.h
@@ -38,7 +38,12 @@ namespace logv2 {
class LogOptions {
public:
- LogOptions() {}
+ static LogOptions ensureValidComponent(LogOptions options, LogComponent component) {
+ if (options._component == LogComponent::kAutomaticDetermination) {
+ options._component = component;
+ }
+ return options;
+ }
LogOptions(LogComponent component) : _component(component) {}
@@ -64,11 +69,7 @@ public:
private:
LogDomain* _domain = &LogManager::global().getGlobalDomain();
LogTag _tags;
-#ifdef MONGO_LOGV2_DEFAULT_COMPONENT
- LogComponent _component = MongoLogV2DefaultComponent_component;
-#else
- LogComponent _component = LogComponent::kDefault;
-#endif // MONGO_LOGV2_DEFAULT_COMPONENT
+ LogComponent _component = LogComponent::kAutomaticDetermination;
};
} // namespace logv2