summaryrefslogtreecommitdiff
path: root/src/mongo/unittest
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2020-02-26 22:58:46 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-27 19:23:39 +0000
commitff724b466d7bc7ead68eacd5524cc1185b8b4523 (patch)
treeab550e052883eb26ad7321663cb2f6066e43ce28 /src/mongo/unittest
parent9a421e19cef1caa2627d4776db700ae5c8751932 (diff)
downloadmongo-ff724b466d7bc7ead68eacd5524cc1185b8b4523.tar.gz
SERVER-46405 Remove {get,set,clear}MinimumLoggedSeverity from logger V1 API
Diffstat (limited to 'src/mongo/unittest')
-rw-r--r--src/mongo/unittest/log_test.h66
-rw-r--r--src/mongo/unittest/unittest_main.cpp3
2 files changed, 68 insertions, 1 deletions
diff --git a/src/mongo/unittest/log_test.h b/src/mongo/unittest/log_test.h
new file mode 100644
index 00000000000..9f48830d958
--- /dev/null
+++ b/src/mongo/unittest/log_test.h
@@ -0,0 +1,66 @@
+/**
+ * Copyright (C) 2020-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#pragma once
+
+#include "mongo/logv2/log_component.h"
+#include "mongo/logv2/log_component_settings.h"
+#include "mongo/logv2/log_manager.h"
+#include "mongo/logv2/log_severity.h"
+
+namespace mongo {
+
+inline logv2::LogSeverity getMinimumLogSeverity() {
+ return logv2::LogManager::global().getGlobalSettings().getMinimumLogSeverity(
+ mongo::logv2::LogComponent::kDefault);
+}
+
+inline logv2::LogSeverity getMinimumLogSeverity(logv2::LogComponent component) {
+ return logv2::LogManager::global().getGlobalSettings().getMinimumLogSeverity(component);
+}
+
+inline void setMinimumLoggedSeverity(logv2::LogSeverity severity) {
+ return logv2::LogManager::global().getGlobalSettings().setMinimumLoggedSeverity(
+ mongo::logv2::LogComponent::kDefault, severity);
+}
+
+inline void setMinimumLoggedSeverity(logv2::LogComponent component, logv2::LogSeverity severity) {
+ return logv2::LogManager::global().getGlobalSettings().setMinimumLoggedSeverity(component,
+ severity);
+}
+
+inline void clearMinimumLoggedSeverity(logv2::LogComponent component) {
+ return logv2::LogManager::global().getGlobalSettings().clearMinimumLoggedSeverity(component);
+}
+
+inline bool hasMinimumLogSeverity(logv2::LogComponent component) {
+ return logv2::LogManager::global().getGlobalSettings().hasMinimumLogSeverity(component);
+}
+
+} // namespace mongo
diff --git a/src/mongo/unittest/unittest_main.cpp b/src/mongo/unittest/unittest_main.cpp
index f7bcd647c1a..3ddb44f977d 100644
--- a/src/mongo/unittest/unittest_main.cpp
+++ b/src/mongo/unittest/unittest_main.cpp
@@ -36,6 +36,7 @@
#include "mongo/logger/logger.h"
#include "mongo/logv2/log_domain_global.h"
#include "mongo/logv2/log_manager.h"
+#include "mongo/unittest/log_test.h"
#include "mongo/unittest/unittest.h"
#include "mongo/unittest/unittest_options_gen.h"
#include "mongo/util/log_global_settings.h"
@@ -94,7 +95,7 @@ int main(int argc, char** argv, char** envp) {
std::cerr << options.helpString();
return EXIT_FAILURE;
}
- mongo::setMinimumLoggedSeverity(::mongo::logger::LogSeverity::Debug(verbose.length()));
+ mongo::setMinimumLoggedSeverity(::mongo::logv2::LogSeverity::Debug(verbose.length()));
if (list) {
auto suiteNames = ::mongo::unittest::getAllSuiteNames();