summaryrefslogtreecommitdiff
path: root/src/mongo/logv2/json_formatter.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-01-30 15:35:37 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-01-31 19:35:45 +0000
commit6e434fb427ae79cf5f4951a3ee1ab534b81278a9 (patch)
tree604293a47d61311001fbb64a8d6370706fd8e1be /src/mongo/logv2/json_formatter.cpp
parentdf03d4ddc092ca3616575dd6ec08f7c4852d51e0 (diff)
downloadmongo-6e434fb427ae79cf5f4951a3ee1ab534b81278a9.tar.gz
SERVER-45887 Log message string can use named replacement fields
delete mode 100644 src/mongo/logv2/named_arg_formatter.h
Diffstat (limited to 'src/mongo/logv2/json_formatter.cpp')
-rw-r--r--src/mongo/logv2/json_formatter.cpp26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/mongo/logv2/json_formatter.cpp b/src/mongo/logv2/json_formatter.cpp
index 2bbf9570465..22583dd45eb 100644
--- a/src/mongo/logv2/json_formatter.cpp
+++ b/src/mongo/logv2/json_formatter.cpp
@@ -43,7 +43,6 @@
#include "mongo/logv2/log_severity.h"
#include "mongo/logv2/log_tag.h"
#include "mongo/logv2/name_extractor.h"
-#include "mongo/logv2/named_arg_formatter.h"
#include "mongo/util/str_escape.h"
#include "mongo/util/time_support.h"
@@ -170,7 +169,7 @@ void JSONFormatter::operator()(boost::log::record_view const& rec,
R"("{}":"{}"{: <{}})" // component with padding for the comma
R"("{}":{},)" // id
R"("{}":"{}",)" // context
- R"("{}":")", // message
+ R"("{}":"{}")", // message
// timestamp
constants::kTimestampFieldName,
dateToISOStringUTC(extract<Date_t>(attributes::timeStamp(), rec).get()),
@@ -191,28 +190,11 @@ void JSONFormatter::operator()(boost::log::record_view const& rec,
constants::kContextFieldName,
extract<StringData>(attributes::threadName(), rec).get(),
// message
- constants::kMessageFieldName);
-
- // Insert the attribute names back into the message string using a special formatter and format
- // into buffer
- detail::NameExtractor nameExtractor;
- attrs.apply(nameExtractor);
-
- fmt::vformat_to<detail::NamedArgFormatter, char>(
- buffer,
- extract<StringData>(attributes::message(), rec).get().toString(),
- fmt::basic_format_args<fmt::format_context>(nameExtractor.nameArgs.data(),
- nameExtractor.nameArgs.size()));
-
- if (attrs.empty()) {
- // If no attributes we can just close the message string
- buffer.push_back('"');
- } else {
- // otherwise, add attribute field name and opening brace
- fmt::format_to(buffer, R"(","{}":{{)", constants::kAttributesFieldName);
- }
+ constants::kMessageFieldName,
+ extract<StringData>(attributes::message(), rec).get());
if (!attrs.empty()) {
+ fmt::format_to(buffer, R"(,"{}":{{)", constants::kAttributesFieldName);
// comma separated list of attributes (no opening/closing brace are added here)
JSONValueExtractor extractor(buffer);
attrs.apply(extractor);