diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2020-02-13 11:49:46 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-13 18:16:35 +0000 |
commit | a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761 (patch) | |
tree | 85ac46cd5f4ea6d5134560bf764fb9e6cf11fe4e /src/mongo/util/log.cpp | |
parent | 6df40e01f7b6899affc4536e7e73a35802cabf98 (diff) | |
download | mongo-a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761.tar.gz |
SERVER-45869 automatically converted structured logging
Diffstat (limited to 'src/mongo/util/log.cpp')
-rw-r--r-- | src/mongo/util/log.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mongo/util/log.cpp b/src/mongo/util/log.cpp index 9a9d7099e4a..a60fd216972 100644 --- a/src/mongo/util/log.cpp +++ b/src/mongo/util/log.cpp @@ -33,6 +33,7 @@ #include "mongo/platform/basic.h" +#include "mongo/logv2/log.h" #include "mongo/util/log.h" #include "mongo/config.h" @@ -84,12 +85,12 @@ Status logger::registerExtraLogContextFn(logger::ExtraLogContextFn contextFn) { bool rotateLogs(bool renameFiles) { // Rotate on both logv1 and logv2 so all files that need rotation gets rotated - log() << "Log rotation initiated"; + LOGV2(23166, "Log rotation initiated"); std::string suffix = "." + terseCurrentTime(false); Status resultv2 = logv2::LogManager::global().getGlobalDomainInternal().rotate(renameFiles, suffix); if (!resultv2.isOK()) - warning() << "Log rotation failed: " << resultv2; + LOGV2_WARNING(23168, "Log rotation failed: {resultv2}", "resultv2"_attr = resultv2); using logger::RotatableFileManager; RotatableFileManager* manager = logger::globalRotatableFileManager(); @@ -97,14 +98,17 @@ bool rotateLogs(bool renameFiles) { for (RotatableFileManager::FileNameStatusPairVector::iterator it = result.begin(); it != result.end(); it++) { - warning() << "Rotating log file " << it->first << " failed: " << it->second.toString(); + LOGV2_WARNING(23169, + "Rotating log file {it_first} failed: {it_second}", + "it_first"_attr = it->first, + "it_second"_attr = it->second.toString()); } return resultv2.isOK() && result.empty(); } void logContext(const char* errmsg) { if (errmsg) { - log() << errmsg << std::endl; + LOGV2(23167, "{errmsg}", "errmsg"_attr = errmsg); } // NOTE: We disable long-line truncation for the stack trace, because the JSON representation of // the stack trace can sometimes exceed the long line limit. |