diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-02-18 11:24:56 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-18 20:01:54 +0000 |
commit | dcd6636336bf1dc3079143456be63a4e135cb609 (patch) | |
tree | 6b0ee8703d2ec0fd2e595e38e77ef348df20733e /src | |
parent | 3ad579abbc5953d5a4e23907753b8da258521a19 (diff) | |
download | mongo-dcd6636336bf1dc3079143456be63a4e135cb609.tar.gz |
SERVER-46224 JSON formatter escapes message string
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/logv2/json_formatter.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/logv2/json_formatter.cpp b/src/mongo/logv2/json_formatter.cpp index 61c73d9c0a1..a51366b8f72 100644 --- a/src/mongo/logv2/json_formatter.cpp +++ b/src/mongo/logv2/json_formatter.cpp @@ -232,7 +232,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 // severity, left align the comma and add padding to create fixed column width constants::kSeverityFieldName, severity, @@ -250,8 +250,10 @@ void JSONFormatter::operator()(boost::log::record_view const& rec, constants::kContextFieldName, extract<StringData>(attributes::threadName(), rec).get(), // message - constants::kMessageFieldName, - extract<StringData>(attributes::message(), rec).get()); + constants::kMessageFieldName); + + str::escapeForJSON(buffer, extract<StringData>(attributes::message(), rec).get()); + buffer.push_back('"'); if (!attrs.empty()) { fmt::format_to(buffer, R"(,"{}":{{)", constants::kAttributesFieldName); |