mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-47072 Align the id in JSON log output
This commit is contained in:
parent
0c09d563ca
commit
0ff2d7877e
@ -20,7 +20,7 @@ function runTest(bindIP, expectOk) {
|
||||
assert.soonNoExcept(() => {
|
||||
const logContents = rawMongoProgramOutput();
|
||||
const found = logContents.match(
|
||||
/"id":23016,"ctx":"listener","msg":"Waiting for connections","attr":{"port":(\d+)/);
|
||||
/"id":23016,\s*"ctx":"listener","msg":"Waiting for connections","attr":{"port":(\d+)/);
|
||||
if (found !== null) {
|
||||
print("Found message from mongod with port it is listening on: " + found[0]);
|
||||
port = found[1];
|
||||
|
@ -23,7 +23,7 @@ function validateWaitingMessage(launcher) {
|
||||
testStartupLogging(
|
||||
launcher,
|
||||
makeRegExMatchFn(
|
||||
/"id":23016,"ctx":"listener","msg":"Waiting for connections","attr":{"port":/));
|
||||
/"id":23016,\s*"ctx":"listener","msg":"Waiting for connections","attr":{"port":/));
|
||||
}
|
||||
|
||||
print("********************\nTesting startup logging in mongod\n********************");
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user