From bc67d9be07b35da807ae854960e24f9ed61e5d43 Mon Sep 17 00:00:00 2001 From: Amirsaman Memaripour Date: Thu, 26 Mar 2020 10:45:50 -0400 Subject: SERVER-47077 Clean up log lines in 'mongo/db' Cleaning up log lines to adhere to the LOGV2 style guide. --- src/mongo/db/commands.cpp | 46 ++++++++++++++----------- src/mongo/db/initialize_server_global_state.cpp | 15 ++++---- src/mongo/db/log_process_details.cpp | 4 +-- src/mongo/db/mongod_options.cpp | 10 +++--- src/mongo/db/operation_killer.cpp | 2 +- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 57b65cca648..3085027db40 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -614,9 +614,9 @@ void CommandHelpers::evaluateFailCommandFailPoint(OperationContext* opCtx, if (closeConnection) { opCtx->getClient()->session()->end(); LOGV2(20431, - "Failing command '{cmd_getName}' via 'failCommand' failpoint. Action: " - "closing connection.", - "cmd_getName"_attr = cmd->getName()); + "Failing {command} via 'failCommand' failpoint: closing connection", + "Failing command via 'failCommand' failpoint: closing connection", + "command"_attr = cmd->getName()); uasserted(50985, "Failing command due to 'failCommand' failpoint"); } @@ -631,32 +631,35 @@ void CommandHelpers::evaluateFailCommandFailPoint(OperationContext* opCtx, blockTimeMS >= 0); LOGV2(20432, - "Blocking command '{cmd_getName}' via 'failCommand' failpoint for " - "{blockTimeMS} milliseconds", - "cmd_getName"_attr = cmd->getName(), - "blockTimeMS"_attr = blockTimeMS); + "Blocking {command} via 'failCommand' failpoint for {blockTime}", + "Blocking command via 'failCommand' failpoint", + "command"_attr = cmd->getName(), + "blockTime"_attr = Milliseconds{blockTimeMS}); opCtx->sleepFor(Milliseconds{blockTimeMS}); LOGV2(20433, - "Unblocking command '{cmd_getName}' via 'failCommand' failpoint", - "cmd_getName"_attr = cmd->getName()); + "Unblocking {command} via 'failCommand' failpoint", + "Unblocking command via 'failCommand' failpoint", + "command"_attr = cmd->getName()); } if (hasExtraInfo) { LOGV2(20434, - "Failing command '{cmd_getName}' via 'failCommand' failpoint. Action: " - "returning error code {errorCode} and {errorExtraInfo}.", - "cmd_getName"_attr = cmd->getName(), + "Failing {command} via 'failCommand' failpoint: returning {errorCode} and " + "{errorExtraInfo}", + "Failing command via 'failCommand' failpoint", + "command"_attr = cmd->getName(), "errorCode"_attr = errorCode, "errorExtraInfo"_attr = errorExtraInfo); uassertStatusOK(Status(ErrorCodes::Error(errorCode), "Failing command due to 'failCommand' failpoint", errorExtraInfo.Obj())); } else if (hasErrorCode) { - LOGV2(20435, - "Failing command '{cmd_getName}' via 'failCommand' failpoint. Action: " - "returning error code {errorCode}.", - "cmd_getName"_attr = cmd->getName(), - "errorCode"_attr = errorCode); + LOGV2( + 20435, + "Failing command {command} via 'failCommand' failpoint: returning {errorCode}", + "Failing command via 'failCommand' failpoint", + "command"_attr = cmd->getName(), + "errorCode"_attr = errorCode); uasserted(ErrorCodes::Error(errorCode), "Failing command due to 'failCommand' failpoint"); } @@ -741,10 +744,11 @@ void CommandInvocation::checkAuthorization(OperationContext* opCtx, } } } catch (const DBException& e) { - LOGV2_OPTIONS(20436, - {logComponentV1toV2(LogComponent::kAccessControl)}, - "{e_toStatus}", - "e_toStatus"_attr = e.toStatus()); + LOGV2_ERROR_OPTIONS(20436, + {logComponentV1toV2(LogComponent::kAccessControl)}, + "Checking authorization failed: {error}", + "Checking authorization failed", + "error"_attr = e.toStatus()); CommandHelpers::auditLogAuthEvent(opCtx, this, request, e.code()); throw; } diff --git a/src/mongo/db/initialize_server_global_state.cpp b/src/mongo/db/initialize_server_global_state.cpp index 9fb791ecc30..dbcfb3623f8 100644 --- a/src/mongo/db/initialize_server_global_state.cpp +++ b/src/mongo/db/initialize_server_global_state.cpp @@ -111,7 +111,7 @@ void signalForkSuccess() { if (close(*f) == -1) { int savedErr = errno; LOGV2_WARNING(4656301, - "closing write pipe failed", + "Closing write pipe failed", "errno"_attr = savedErr, "errnoDesc"_attr = errnoWithDescription(savedErr)); } @@ -378,9 +378,10 @@ MONGO_INITIALIZER_GENERAL(ServerLogRedirection, boost::filesystem::rename(absoluteLogpath, renameTarget, ec); if (!ec) { LOGV2(20697, - "log file \"{absoluteLogpath}\" exists; moved to \"{renameTarget}\".", - "absoluteLogpath"_attr = absoluteLogpath, - "renameTarget"_attr = renameTarget); + "Moving existing log file \"{oldLogPath}\" to \"{newLogPath}\"", + "Renamed existing log file", + "oldLogPath"_attr = absoluteLogpath, + "newLogPath"_attr = renameTarget); } else { return Status(ErrorCodes::FileRenameFailed, str::stream() @@ -427,7 +428,8 @@ MONGO_INITIALIZER_GENERAL(ServerLogRedirection, javascriptAppender = std::make_unique>( std::make_unique(), writer.getValue()); if (serverGlobalParams.logAppend && exists) { - LOGV2(20699, "***** SERVER RESTARTED *****"); + LOGV2_WARNING_OPTIONS( + 20699, {logv2::LogTag::kStartupWarnings}, "***** SERVER RESTARTED *****"); Status status = logger::RotatableFileWriter::Use(writer.getValue()).status(); if (!status.isOK()) return status; @@ -464,7 +466,8 @@ MONGO_INITIALIZER_GENERAL(ServerLogRedirection, lv2Config.timestampFormat = serverGlobalParams.logTimestampFormat; Status result = lv2Manager.getGlobalDomainInternal().configure(lv2Config); if (result.isOK() && writeServerRestartedAfterLogConfig) - LOGV2(20698, "***** SERVER RESTARTED *****"); + LOGV2_WARNING_OPTIONS( + 20698, {logv2::LogTag::kStartupWarnings}, "***** SERVER RESTARTED *****"); return result; } diff --git a/src/mongo/db/log_process_details.cpp b/src/mongo/db/log_process_details.cpp index f63401df6fd..744c478d6ca 100644 --- a/src/mongo/db/log_process_details.cpp +++ b/src/mongo/db/log_process_details.cpp @@ -95,11 +95,11 @@ void logProcessDetailsForLogRotate(ServiceContext* serviceContext) { if (rsConfig.isInitialized()) { LOGV2(20722, - "Replica Set Config", + "Node is a member of a replica set", "config"_attr = rsConfig, "memberState"_attr = replCoord->getMemberState()); } else { - LOGV2(20724, "Node currently has no Replica Set Config."); + LOGV2(20724, "Node currently has no replica set config"); } } diff --git a/src/mongo/db/mongod_options.cpp b/src/mongo/db/mongod_options.cpp index 5087f08864a..e0d4cf05cd5 100644 --- a/src/mongo/db/mongod_options.cpp +++ b/src/mongo/db/mongod_options.cpp @@ -568,11 +568,9 @@ Status storeMongodOptions(const moe::Environment& params) { if (params.count("replication.enableMajorityReadConcern") && !params["replication.enableMajorityReadConcern"].as()) { - LOGV2_WARNING( - 20879, - "Config servers require majority read concern, but it was explicitly " - "disabled. The override is being ignored and the process is continuing " - "with majority read concern enabled."); + LOGV2_WARNING(20879, + "Ignoring read concern override as config server requires majority " + "read concern"); } serverGlobalParams.enableMajorityReadConcern = true; @@ -630,7 +628,7 @@ Status storeMongodOptions(const moe::Environment& params) { LOGV2(20877, ""); LOGV2_WARNING(20880, "32-bit servers don't have journaling enabled by default. Please use " - "--journal if you want durability."); + "--journal if you want durability"); LOGV2(20878, ""); } diff --git a/src/mongo/db/operation_killer.cpp b/src/mongo/db/operation_killer.cpp index 971b789e806..0cfa250504a 100644 --- a/src/mongo/db/operation_killer.cpp +++ b/src/mongo/db/operation_killer.cpp @@ -82,7 +82,7 @@ void OperationKiller::killOperation(OperationId opId) { serviceContext->killOperation(target, target->getOperationContext()); - LOGV2(20884, "Killed operation: {opId}", "opId"_attr = opId); + LOGV2(20884, "Killed operation: {opId}", "Killed operation", "opId"_attr = opId); } void OperationKiller::killOperation(const OperationKey& opKey) { -- cgit v1.2.1