diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2017-11-06 17:32:40 -0500 |
---|---|---|
committer | Henrik Edin <henrik.edin@mongodb.com> | 2017-11-10 15:09:15 -0500 |
commit | 65f7b8f30acd7f498ce6fc1c07ffc0d8d0f058c8 (patch) | |
tree | 3e69e727f3b29cb05ae4047dd821ee8bb8df392d | |
parent | 0f65aee23327e9f47708ac7306d7769035f1945f (diff) | |
download | mongo-65f7b8f30acd7f498ce6fc1c07ffc0d8d0f058c8.tar.gz |
SERVER-31811 Remove logging of binary data.
-rw-r--r-- | src/mongo/executor/network_interface_asio_command.cpp | 28 |
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); } |