From fad9de4ece9f5399acc804f206e40621930be5af Mon Sep 17 00:00:00 2001 From: Billy Donahue Date: Tue, 16 Feb 2021 01:15:53 -0500 Subject: SERVER-54596 remove 1-arg shouldLog function (an ODR violation) --- src/mongo/db/matcher/schema/json_schema_parser.cpp | 3 ++- src/mongo/db/repl/isself.cpp | 4 ++-- src/mongo/db/service_entry_point_common.cpp | 2 +- src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp | 2 +- src/mongo/logv2/log.h | 5 ----- src/mongo/scripting/mozjs/engine.cpp | 4 ++-- src/mongo/scripting/mozjs/implscope.cpp | 2 +- src/mongo/util/net/sock.cpp | 3 ++- 8 files changed, 11 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mongo/db/matcher/schema/json_schema_parser.cpp b/src/mongo/db/matcher/schema/json_schema_parser.cpp index c972c05c602..df73cced7a7 100644 --- a/src/mongo/db/matcher/schema/json_schema_parser.cpp +++ b/src/mongo/db/matcher/schema/json_schema_parser.cpp @@ -1870,7 +1870,8 @@ StatusWithMatchExpression JSONSchemaParser::parse( "schema"_attr = schema.jsonString(JsonStringFormat::LegacyStrict)); try { auto translation = _parse(expCtx, ""_sd, schema, allowedFeatures, ignoreUnknownKeywords); - if (shouldLog(logv2::LogSeverity::Debug(5)) && translation.isOK()) { + if (shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, logv2::LogSeverity::Debug(5)) && + translation.isOK()) { LOGV2_DEBUG(20729, 5, "Translated schema match expression: {expression}", diff --git a/src/mongo/db/repl/isself.cpp b/src/mongo/db/repl/isself.cpp index 98d4f1cef78..adb93ac45a9 100644 --- a/src/mongo/db/repl/isself.cpp +++ b/src/mongo/db/repl/isself.cpp @@ -149,7 +149,7 @@ std::vector getAddrsForHost(const std::string& iporhost, } } - if (shouldLog(logv2::LogSeverity::Debug(2))) { + if (shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, logv2::LogSeverity::Debug(2))) { LOGV2_DEBUG(21205, 2, "getAddrsForHost()", @@ -397,7 +397,7 @@ std::vector getBoundAddrs(const bool ipv6enabled) { #endif // defined(_WIN32) - if (shouldLog(logv2::LogSeverity::Debug(2))) { + if (shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, logv2::LogSeverity::Debug(2))) { LOGV2_DEBUG(21206, 2, "getBoundAddrs()", "result"_attr = out); } return out; diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index 164a07dbb2d..0abb6b54bc9 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -1958,7 +1958,7 @@ void receivedKillCursors(OperationContext* opCtx, const Message& m) { const char* cursorArray = dbmessage.getArray(n); int found = runOpKillCursors(opCtx, static_cast(n), cursorArray); - if (shouldLog(logv2::LogSeverity::Debug(1)) || found != n) { + if (shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, logv2::LogSeverity::Debug(1)) || found != n) { LOGV2_DEBUG(21967, found == n ? 1 : 0, "killCursors: found {found} of {numCursors}", diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp index 738c2d432e8..6e47bba47fc 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp @@ -565,7 +565,7 @@ void WiredTigerRecoveryUnit::_txnOpen() { _ensureSession(); // Only start a timer for transaction's lifetime if we're going to log it. - if (shouldLog(kSlowTransactionSeverity)) { + if (shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, kSlowTransactionSeverity)) { _timer.reset(new Timer()); } WT_SESSION* session = _session->getSession(); diff --git a/src/mongo/logv2/log.h b/src/mongo/logv2/log.h index 38bc39cfda3..7cfe6aa4ec3 100644 --- a/src/mongo/logv2/log.h +++ b/src/mongo/logv2/log.h @@ -299,11 +299,6 @@ namespace mongo { FMTSTR_MESSAGE, \ ##__VA_ARGS__) -inline bool shouldLog(logv2::LogSeverity severity) { - return logv2::LogManager::global().getGlobalSettings().shouldLog( - MongoLogV2DefaultComponent_component, severity); -} - inline bool shouldLog(logv2::LogComponent logComponent, logv2::LogSeverity severity) { return logv2::LogManager::global().getGlobalSettings().shouldLog(logComponent, severity); } diff --git a/src/mongo/scripting/mozjs/engine.cpp b/src/mongo/scripting/mozjs/engine.cpp index faad11b70ae..b4069e76ca2 100644 --- a/src/mongo/scripting/mozjs/engine.cpp +++ b/src/mongo/scripting/mozjs/engine.cpp @@ -93,7 +93,7 @@ void MozJSScriptEngine::interrupt(unsigned opId) { OpIdToScopeMap::iterator iScope = _opToScopeMap.find(opId); if (iScope == _opToScopeMap.end()) { // got interrupt request for a scope that no longer exists - if (shouldLog(logv2::LogSeverity::Debug(3))) { + if (shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, logv2::LogSeverity::Debug(3))) { // This log record gets extra attributes when the log severity is at Debug(3) // but we still log the record at log severity Debug(2). Simplify this if SERVER-48671 // gets done @@ -107,7 +107,7 @@ void MozJSScriptEngine::interrupt(unsigned opId) { } return; } - if (shouldLog(logv2::LogSeverity::Debug(3))) { + if (shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, logv2::LogSeverity::Debug(3))) { // Like above, this log record gets extra attributes when the log severity is at Debug(3) LOGV2_DEBUG(22809, 2, "Interrupting op", "opId"_attr = opId, "knownOps"_attr = knownOps()); } else { diff --git a/src/mongo/scripting/mozjs/implscope.cpp b/src/mongo/scripting/mozjs/implscope.cpp index 3834fff7629..097ecd1304a 100644 --- a/src/mongo/scripting/mozjs/implscope.cpp +++ b/src/mongo/scripting/mozjs/implscope.cpp @@ -233,7 +233,7 @@ bool MozJSImplScope::_interruptCallback(JSContext* cx) { } void MozJSImplScope::_gcCallback(JSContext* rt, JSGCStatus status, void* data) { - if (!shouldLog(logv2::LogSeverity::Debug(1))) { + if (!shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, logv2::LogSeverity::Debug(1))) { // don't collect stats unless verbose return; } diff --git a/src/mongo/util/net/sock.cpp b/src/mongo/util/net/sock.cpp index d299512f48a..e4fecc5b23c 100644 --- a/src/mongo/util/net/sock.cpp +++ b/src/mongo/util/net/sock.cpp @@ -116,7 +116,8 @@ void networkWarnWithDescription(const Socket& socket, StringData call, int error const double kMaxConnectTimeoutMS = 5000; void setSockTimeouts(int sock, double secs) { - bool report = shouldLog(logv2::LogSeverity::Debug(4)) || kDebugBuild; + bool report = + shouldLog(MONGO_LOGV2_DEFAULT_COMPONENT, logv2::LogSeverity::Debug(4)) || kDebugBuild; #if defined(_WIN32) DWORD timeout = secs * 1000; // Windows timeout is a DWORD, in milliseconds. int status = -- cgit v1.2.1