diff options
author | Kevin Pulo <kevin.pulo@mongodb.com> | 2018-11-14 06:57:42 +0000 |
---|---|---|
committer | Kevin Pulo <kevin.pulo@mongodb.com> | 2018-11-21 05:29:45 +0000 |
commit | 3aa006e505e3f65a9272f637b816e17eaf0dadb3 (patch) | |
tree | 6c88e03d41d982e9f5a41bbb237bdd5f42242958 | |
parent | 74e5e8949bcc62bde1f1455b463fc89f07649ead (diff) | |
download | mongo-3aa006e505e3f65a9272f637b816e17eaf0dadb3.tar.gz |
SERVER-37740 SERVER-37741 remove deprecated LabeledLevel
-rw-r--r-- | src/mongo/logger/labeled_level.h | 105 | ||||
-rw-r--r-- | src/mongo/logger/log_severity.h | 3 | ||||
-rw-r--r-- | src/mongo/logger/logstream_builder.cpp | 7 | ||||
-rw-r--r-- | src/mongo/logger/logstream_builder.h | 9 | ||||
-rw-r--r-- | src/mongo/s/client/parallel.cpp | 40 | ||||
-rw-r--r-- | src/mongo/util/log.h | 1 |
6 files changed, 20 insertions, 145 deletions
diff --git a/src/mongo/logger/labeled_level.h b/src/mongo/logger/labeled_level.h deleted file mode 100644 index b4e7de4d6af..00000000000 --- a/src/mongo/logger/labeled_level.h +++ /dev/null @@ -1,105 +0,0 @@ - -/** - * Copyright (C) 2018-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 <string> - -#include "mongo/logger/log_severity.h" - -namespace mongo { -namespace logger { - -/** - * Deprecated utility for associating a std::string and log level together. - */ -class LabeledLevel { -public: - LabeledLevel(int level) : _level(level) {} - LabeledLevel(const char* label, int level) : _label(label), _level(level) {} - LabeledLevel(const std::string& label, int level) : _label(label), _level(level) {} - - LabeledLevel operator+(int i) const { - return LabeledLevel(_label, _level + i); - } - - LabeledLevel operator-(int i) const { - return LabeledLevel(_label, _level - i); - } - - const std::string& getLabel() const { - return _label; - } - int getLevel() const { - return _level; - } - - operator LogSeverity() const { - return logger::LogSeverity::cast(_level); - } - -private: - std::string _label; - int _level; -}; - -inline bool operator<(const LabeledLevel& ll, const int i) { - return ll.getLevel() < i; -} -inline bool operator<(const int i, const LabeledLevel& ll) { - return i < ll.getLevel(); -} -inline bool operator>(const LabeledLevel& ll, const int i) { - return ll.getLevel() > i; -} -inline bool operator>(const int i, const LabeledLevel& ll) { - return i > ll.getLevel(); -} -inline bool operator<=(const LabeledLevel& ll, const int i) { - return ll.getLevel() <= i; -} -inline bool operator<=(const int i, const LabeledLevel& ll) { - return i <= ll.getLevel(); -} -inline bool operator>=(const LabeledLevel& ll, const int i) { - return ll.getLevel() >= i; -} -inline bool operator>=(const int i, const LabeledLevel& ll) { - return i >= ll.getLevel(); -} -inline bool operator==(const LabeledLevel& ll, const int i) { - return ll.getLevel() == i; -} -inline bool operator==(const int i, const LabeledLevel& ll) { - return i == ll.getLevel(); -} - -} // namespace logger -} // namespace mongo diff --git a/src/mongo/logger/log_severity.h b/src/mongo/logger/log_severity.h index c17b63b24f4..d757c733488 100644 --- a/src/mongo/logger/log_severity.h +++ b/src/mongo/logger/log_severity.h @@ -60,8 +60,7 @@ public: /** * Casts an integer to a severity. * - * Do not use this. It exists to enable a handful of leftover uses of LOG(0) and the - * deprecated LabeledLevel. + * Do not use this. It exists to enable a handful of leftover uses of LOG(0). */ static inline LogSeverity cast(int); diff --git a/src/mongo/logger/logstream_builder.cpp b/src/mongo/logger/logstream_builder.cpp index 201130579e9..b6e1cdd0fe3 100644 --- a/src/mongo/logger/logstream_builder.cpp +++ b/src/mongo/logger/logstream_builder.cpp @@ -88,13 +88,6 @@ LogstreamBuilder::LogstreamBuilder(MessageLogDomain* domain, _tee(nullptr), _shouldCache(shouldCache) {} -LogstreamBuilder::LogstreamBuilder(logger::MessageLogDomain* domain, - StringData contextName, - LabeledLevel labeledLevel) - : LogstreamBuilder(domain, contextName, static_cast<LogSeverity>(labeledLevel)) { - setBaseMessage(labeledLevel.getLabel()); -} - LogstreamBuilder::~LogstreamBuilder() { if (_os) { if (!_baseMessage.empty()) diff --git a/src/mongo/logger/logstream_builder.h b/src/mongo/logger/logstream_builder.h index 38ac98ed6b0..b93c67b4eab 100644 --- a/src/mongo/logger/logstream_builder.h +++ b/src/mongo/logger/logstream_builder.h @@ -37,7 +37,6 @@ #include "mongo/base/error_codes.h" #include "mongo/bson/bsontypes.h" -#include "mongo/logger/labeled_level.h" #include "mongo/logger/log_component.h" #include "mongo/logger/log_severity.h" #include "mongo/logger/message_log_domain.h" @@ -60,9 +59,6 @@ public: static LogSeverity severityCast(LogSeverity ls) { return ls; } - static LabeledLevel severityCast(const LabeledLevel& labeled) { - return labeled; - } /** * Construct a LogstreamBuilder that writes to "domain" on destruction. @@ -90,11 +86,6 @@ public: LogComponent component, bool shouldCache = true); - /** - * Deprecated. - */ - LogstreamBuilder(MessageLogDomain* domain, StringData contextName, LabeledLevel labeledLevel); - LogstreamBuilder(LogstreamBuilder&& other) = default; LogstreamBuilder& operator=(LogstreamBuilder&& other) = default; diff --git a/src/mongo/s/client/parallel.cpp b/src/mongo/s/client/parallel.cpp index 83b7d8a0daf..485acc45ce4 100644 --- a/src/mongo/s/client/parallel.cpp +++ b/src/mongo/s/client/parallel.cpp @@ -60,8 +60,6 @@ namespace dps = ::mongo::dotted_path_support; namespace { -LabeledLevel pc("pcursor", 2); - /** * Throws an exception wrapping the error document in this cursor when the error flag is set. */ @@ -390,8 +388,8 @@ void ParallelSortClusteredCursor::setupVersionAndHandleSlaveOk( try { if (state->conn->setVersion()) { - LOG(pc) << "needed to set remote version on connection to value " - << "compatible with " << vinfo; + LOG(2) << "pcursor: needed to set remote version on connection to value " + << "compatible with " << vinfo; } } catch (const DBException& dbExcep) { auto errCode = dbExcep.code(); @@ -421,14 +419,14 @@ void ParallelSortClusteredCursor::startInit(OperationContext* opCtx) { const NamespaceString nss(!_cInfo.isEmpty() ? _cInfo.versionedNS : _qSpec.ns()); string prefix; - if (MONGO_unlikely(shouldLog(pc))) { + if (MONGO_unlikely(shouldLog(logger::LogSeverity::Debug(2)))) { if (_totalTries > 0) { prefix = str::stream() << "retrying (" << _totalTries << " tries)"; } else { prefix = "creating"; } } - LOG(pc) << prefix << " pcursor over " << _qSpec << " and " << _cInfo; + LOG(2) << "pcursor: " << prefix << " pcursor over " << _qSpec << " and " << _cInfo; shared_ptr<ChunkManager> manager; shared_ptr<Shard> primary; @@ -451,7 +449,7 @@ void ParallelSortClusteredCursor::startInit(OperationContext* opCtx) { string vinfo; if (manager) { - if (MONGO_unlikely(shouldLog(pc))) { + if (MONGO_unlikely(shouldLog(logger::LogSeverity::Debug(2)))) { vinfo = str::stream() << "[" << manager->getns().ns() << " @ " << manager->getVersion().toString() << "]"; } @@ -461,7 +459,7 @@ void ParallelSortClusteredCursor::startInit(OperationContext* opCtx) { !_cInfo.isEmpty() ? _cInfo.cmdCollation : BSONObj(), &shardIds); } else if (primary) { - if (MONGO_unlikely(shouldLog(pc))) { + if (MONGO_unlikely(shouldLog(logger::LogSeverity::Debug(2)))) { vinfo = str::stream() << "[unsharded @ " << primary->toString() << "]"; } @@ -473,14 +471,14 @@ void ParallelSortClusteredCursor::startInit(OperationContext* opCtx) { const auto& shardId = cmEntry.first; if (shardIds.find(shardId) == shardIds.end()) { - LOG(pc) << "closing cursor on shard " << shardId - << " as the connection is no longer required by " << vinfo; + LOG(2) << "pcursor: closing cursor on shard " << shardId + << " as the connection is no longer required by " << vinfo; cmEntry.second.cleanup(true); } } - LOG(pc) << "initializing over " << shardIds.size() << " shards required by " << vinfo; + LOG(2) << "pcursor: initializing over " << shardIds.size() << " shards required by " << vinfo; // Don't retry indefinitely for whatever reason _totalTries++; @@ -489,8 +487,8 @@ void ParallelSortClusteredCursor::startInit(OperationContext* opCtx) { for (const ShardId& shardId : shardIds) { auto& mdata = _cursorMap[shardId]; - LOG(pc) << "initializing on shard " << shardId << ", current connection state is " - << mdata.toBSON(); + LOG(2) << "pcursor: initializing on shard " << shardId << ", current connection state is " + << mdata.toBSON(); // This may be the first time connecting to this shard, if so we can get an error here try { @@ -609,9 +607,9 @@ void ParallelSortClusteredCursor::startInit(OperationContext* opCtx) { mdata.finished = true; } - LOG(pc) << "initialized " << (isCommand() ? "command " : "query ") - << (lazyInit ? "(lazily) " : "(full) ") << "on shard " << shardId - << ", current connection state is " << mdata.toBSON(); + LOG(2) << "pcursor: initialized " << (isCommand() ? "command " : "query ") + << (lazyInit ? "(lazily) " : "(full) ") << "on shard " << shardId + << ", current connection state is " << mdata.toBSON(); } catch (StaleConfigException& e) { // Our version isn't compatible with the current version anymore on at least one shard, // need to retry immediately @@ -706,14 +704,14 @@ void ParallelSortClusteredCursor::finishInit(OperationContext* opCtx) { bool retry = false; map<string, StaleConfigException> staleNSExceptions; - LOG(pc) << "finishing over " << _cursorMap.size() << " shards"; + LOG(2) << "pcursor: finishing over " << _cursorMap.size() << " shards"; for (auto& cmEntry : _cursorMap) { const auto& shardId = cmEntry.first; auto& mdata = cmEntry.second; - LOG(pc) << "finishing on shard " << shardId << ", current connection state is " - << mdata.toBSON(); + LOG(2) << "pcursor: finishing on shard " << shardId << ", current connection state is " + << mdata.toBSON(); // Ignore empty conns for now if (!mdata.pcState) @@ -760,8 +758,8 @@ void ParallelSortClusteredCursor::finishInit(OperationContext* opCtx) { // Finalize state state->cursor->attach(state->conn.get()); // Closes connection for us - LOG(pc) << "finished on shard " << shardId << ", current connection state is " - << mdata.toBSON(); + LOG(2) << "pcursor: finished on shard " << shardId + << ", current connection state is " << mdata.toBSON(); } } catch (StaleConfigException& e) { retry = true; diff --git a/src/mongo/util/log.h b/src/mongo/util/log.h index abdb1e752b0..7dd16e6f706 100644 --- a/src/mongo/util/log.h +++ b/src/mongo/util/log.h @@ -79,7 +79,6 @@ Status registerExtraLogContextFn(ExtraLogContextFn contextFn); namespace { using logger::LogstreamBuilder; -using logger::LabeledLevel; using logger::Tee; /** |