From e0ec3c2c1be2bd0d3263d059610579dfc94bfa7d Mon Sep 17 00:00:00 2001 From: Reo Kimura Date: Mon, 29 Jun 2020 23:54:36 +0000 Subject: SERVER-48205 Rewrote toString() functions using fmtlib, locally untested --- src/mongo/executor/remote_command_response.cpp | 31 +++++++++++++++++--------- src/mongo/executor/remote_command_response.h | 1 + 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/mongo/executor/remote_command_response.cpp b/src/mongo/executor/remote_command_response.cpp index 146a3abc70d..f0311b2ce4e 100644 --- a/src/mongo/executor/remote_command_response.cpp +++ b/src/mongo/executor/remote_command_response.cpp @@ -76,11 +76,15 @@ bool RemoteCommandResponseBase::isOK() const { } std::string RemoteCommandResponse::toString() const { - return str::stream() << "RemoteResponse -- " - << " cmd:" << data.toString() << " status: " << status.toString() - << " elapsedMillis: " - << (elapsedMillis != boost::none ? elapsedMillis.get().toString() : "n/a") - << " moreToCome: " << moreToCome; + return format(FMT_STRING("RemoteResponse --" + " cmd: {}" + " status: {}" + " elapsedMillis: {}" + " moreToCome: {}"), + data.toString(), + status.toString(), + elapsedMillis ? StringData(elapsedMillis->toString()) : "n/a"_sd, + moreToCome); } bool RemoteCommandResponse::operator==(const RemoteCommandResponse& rhs) const { @@ -149,12 +153,17 @@ bool RemoteCommandOnAnyResponse::operator!=(const RemoteCommandOnAnyResponse& rh } std::string RemoteCommandOnAnyResponse::toString() const { - return str::stream() << "RemoteOnAnyResponse -- " - << " cmd:" << data.toString() << " target: " - << (!target ? StringData("[none]") : StringData(target->toString())) - << " status: " << status.toString() << " elapsedMillis: " - << (elapsedMillis != boost::none ? elapsedMillis.get().toString() : "n/a") - << " moreToCome: " << moreToCome; + return format(FMT_STRING("RemoteOnAnyResponse -- " + " cmd: {}" + " target: {}" + " status: {}" + " elapsedMillis: {}" + " moreToCome: {}"), + data.toString(), + target ? StringData(target->toString()) : "[none]"_sd, + status.toString(), + elapsedMillis ? StringData(elapsedMillis.get().toString()) : "n/a"_sd, + moreToCome); } std::ostream& operator<<(std::ostream& os, const RemoteCommandOnAnyResponse& response) { diff --git a/src/mongo/executor/remote_command_response.h b/src/mongo/executor/remote_command_response.h index 7842ebdfe14..a49b3deb763 100644 --- a/src/mongo/executor/remote_command_response.h +++ b/src/mongo/executor/remote_command_response.h @@ -30,6 +30,7 @@ #pragma once #include +#include #include #include #include -- cgit v1.2.1