summaryrefslogtreecommitdiff
path: root/src/mongo/logv2
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2020-03-24 11:44:16 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-25 15:39:36 +0000
commit0ff2d7877ee6bb2ea1e745526e85a1a1df39a592 (patch)
tree74ebcd20e2b27971b48ab59957cfc42eb557435a /src/mongo/logv2
parent0c09d563ca9669f0a51f403282274f1a0c4c33cd (diff)
downloadmongo-0ff2d7877ee6bb2ea1e745526e85a1a1df39a592.tar.gz
SERVER-47072 Align the id in JSON log output
Diffstat (limited to 'src/mongo/logv2')
-rw-r--r--src/mongo/logv2/json_formatter.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/mongo/logv2/json_formatter.cpp b/src/mongo/logv2/json_formatter.cpp
index 81007d59c6b..df87a5b40a8 100644
--- a/src/mongo/logv2/json_formatter.cpp
+++ b/src/mongo/logv2/json_formatter.cpp
@@ -245,26 +245,30 @@ void JSONFormatter::format(fmt::memory_buffer& buffer,
outputDateAsISOStringLocal(buffer, date);
break;
};
- static const auto& fmtStrBody = *new auto(
- fmt::compile<StringData,
- StringData,
- StringData,
- int,
- StringData,
- StringData,
- StringData,
- int,
- StringData,
- int32_t,
- StringData,
- StringData,
- StringData>(R"("}},)" // close timestamp
- R"("{}":"{}"{: <{}})" // severity with padding for the comma
- R"("{}":"{}"{: <{}})" // component with padding for the comma
- R"("{}":{},)" // id
- R"("{}":"{}",)" // context
- R"("{}":")" // message
- ));
+ static const auto& fmtStrBody =
+ *new auto(fmt::compile<StringData, // severity start
+ StringData,
+ StringData,
+ int,
+ StringData, // component start
+ StringData,
+ StringData,
+ int,
+ StringData, // id start
+ StringData,
+ StringData,
+ int,
+ StringData, // context start
+ StringData,
+ StringData> // message start
+ (R"("}},)" // close timestamp
+ R"("{}":"{}"{: <{}})" // severity with padding for the comma
+ R"("{}":"{}"{: <{}})" // component with padding for the comma
+ R"("{}":{}{: <{}})" // id with padding for the comma
+ R"("{}":"{}",)" // context
+ R"("{}":")" // message
+ ));
+ fmt::format_int idString(id);
compiled_format_to(
buffer,
fmtStrBody,
@@ -280,7 +284,9 @@ void JSONFormatter::format(fmt::memory_buffer& buffer,
9 - componentString.size(),
// id
constants::kIdFieldName,
- id,
+ StringData(idString.data(), idString.size()),
+ ","_sd,
+ 8 - idString.size(),
// context
constants::kContextFieldName,
context,