summaryrefslogtreecommitdiff
path: root/src/mongo/unittest/unittest.cpp
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2020-04-25 12:23:19 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-26 23:06:52 +0000
commiteae31861e0f813f0099e1d490c4a622d75cd5a08 (patch)
treebcfeb9feeb3bc37ccb1eb3250eca2f91e4bb8523 /src/mongo/unittest/unittest.cpp
parent085ffeb310e8fed49739cf8443fcb13ea795d867 (diff)
downloadmongo-eae31861e0f813f0099e1d490c4a622d75cd5a08.tar.gz
SERVER-47735 change mongo source over to logv2
- Remove several legacy logger/ files - Convert all MONGO_LOG_DEFAULT_COMPONENT to the LOGV2 version. - Globally replace logger::{LogSeverity,LogComponent} => logv2::
Diffstat (limited to 'src/mongo/unittest/unittest.cpp')
-rw-r--r--src/mongo/unittest/unittest.cpp40
1 files changed, 3 insertions, 37 deletions
diff --git a/src/mongo/unittest/unittest.cpp b/src/mongo/unittest/unittest.cpp
index 6ed06953f78..d97a7c93f97 100644
--- a/src/mongo/unittest/unittest.cpp
+++ b/src/mongo/unittest/unittest.cpp
@@ -194,7 +194,7 @@ public:
void stopCapturingLogMessages();
void stopCapturingLogMessagesIfNeeded();
const std::vector<std::string>& getCapturedTextFormatLogMessages() const;
- const std::vector<BSONObj> getCapturedBSONFormatLogMessages() const;
+ std::vector<BSONObj> getCapturedBSONFormatLogMessages() const;
int64_t countTextFormatLogLinesContaining(const std::string& needle);
int64_t countBSONFormatLogLinesIsSubset(const BSONObj needle);
void printCapturedTextFormatLogLines() const;
@@ -245,40 +245,6 @@ void Test::run() {
}
namespace {
-class StringVectorAppender : public logger::MessageLogDomain::EventAppender {
-public:
- explicit StringVectorAppender(std::vector<std::string>* lines) : _lines(lines) {}
- virtual ~StringVectorAppender() {}
- virtual Status append(const logger::MessageLogDomain::Event& event) {
- std::ostringstream _os;
- if (!_encoder.encode(event, _os)) {
- return Status(ErrorCodes::LogWriteFailed, "Failed to append to LogTestAppender.");
- }
- stdx::lock_guard<stdx::mutex> lk(_mutex);
- if (_enabled) {
- _lines->push_back(_os.str());
- }
- return Status::OK();
- }
-
- void enable() {
- stdx::lock_guard<stdx::mutex> lk(_mutex);
- invariant(!_enabled);
- _enabled = true;
- }
-
- void disable() {
- stdx::lock_guard<stdx::mutex> lk(_mutex);
- invariant(_enabled);
- _enabled = false;
- }
-
-private:
- stdx::mutex _mutex; // NOLINT
- bool _enabled = false;
- logger::MessageEventDetailsEncoder _encoder;
- std::vector<std::string>* _lines;
-};
void CaptureLogs::startCapturingLogMessages() {
invariant(!_isCapturingLogMessages);
@@ -321,7 +287,7 @@ const std::vector<std::string>& CaptureLogs::getCapturedTextFormatLogMessages()
return _capturedLogMessages;
}
-const std::vector<BSONObj> CaptureLogs::getCapturedBSONFormatLogMessages() const {
+std::vector<BSONObj> CaptureLogs::getCapturedBSONFormatLogMessages() const {
std::vector<BSONObj> objs;
std::transform(_capturedBSONLogMessages.cbegin(),
_capturedBSONLogMessages.cend(),
@@ -397,7 +363,7 @@ void Test::stopCapturingLogMessages() {
const std::vector<std::string>& Test::getCapturedTextFormatLogMessages() const {
return getCaptureLogs()->getCapturedTextFormatLogMessages();
}
-const std::vector<BSONObj> Test::getCapturedBSONFormatLogMessages() const {
+std::vector<BSONObj> Test::getCapturedBSONFormatLogMessages() const {
return getCaptureLogs()->getCapturedBSONFormatLogMessages();
}
int64_t Test::countTextFormatLogLinesContaining(const std::string& needle) {