summaryrefslogtreecommitdiff
path: root/src/mongo/executor
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2017-11-06 17:32:40 -0500
committerHenrik Edin <henrik.edin@mongodb.com>2017-11-10 15:09:15 -0500
commit65f7b8f30acd7f498ce6fc1c07ffc0d8d0f058c8 (patch)
tree3e69e727f3b29cb05ae4047dd821ee8bb8df392d /src/mongo/executor
parent0f65aee23327e9f47708ac7306d7769035f1945f (diff)
downloadmongo-65f7b8f30acd7f498ce6fc1c07ffc0d8d0f058c8.tar.gz
SERVER-31811 Remove logging of binary data.
Diffstat (limited to 'src/mongo/executor')
-rw-r--r--src/mongo/executor/network_interface_asio_command.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/mongo/executor/network_interface_asio_command.cpp b/src/mongo/executor/network_interface_asio_command.cpp
index 119115e50e2..8102ed93a5f 100644
--- a/src/mongo/executor/network_interface_asio_command.cpp
+++ b/src/mongo/executor/network_interface_asio_command.cpp
@@ -321,12 +321,28 @@ void NetworkInterfaceASIO::_completeOperation(AsyncOp* op, ResponseStatus resp)
if (!resp.isOK()) {
// In the case that resp is not OK, but _inSetup is false, we are using a connection
// that we got from the pool to execute a command, but it failed for some reason.
- if (op->command()) {
- LOG(2) << "Failed to send message: "
- << redact(std::string(op->command()->toSend().buf(),
- op->command()->toSend().buf() +
- op->command()->toSend().size()))
- << ". Reason: " << redact(resp.status);
+ if (op->command() && shouldLog(LogstreamBuilder::severityCast(2))) {
+ const auto performLog = [&resp](Message& message) {
+ LOG(2) << "Failed to send message. Reason: " << redact(resp.status) << ". Message: "
+ << rpc::opMsgRequestFromAnyProtocol(message).body.toString(
+ logger::globalLogDomain()->shouldRedactLogs());
+ };
+
+ // Message might be compressed, decompress in that case so we can log the body
+ Message& maybeCompressed = op->command()->toSend();
+ if (maybeCompressed.operation() != dbCompressed) {
+ performLog(maybeCompressed);
+ } else {
+ StatusWith<Message> decompressedMessage =
+ op->command()->conn().getCompressorManager().decompressMessage(maybeCompressed);
+ if (decompressedMessage.isOK()) {
+ performLog(decompressedMessage.getValue());
+ } else {
+ LOG(2) << "Failed to execute a command. Reason: " << redact(resp.status)
+ << ". Decompression failed with: "
+ << redact(decompressedMessage.getStatus());
+ }
+ }
} else {
LOG(2) << "Failed to execute a command. Reason: " << redact(resp.status);
}