Skip to content

Commit 372cdc7

Browse files
authored
Merge 3a05c56 into c7fc296
2 parents c7fc296 + 3a05c56 commit 372cdc7

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

ydb/core/client/server/grpc_server.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,13 @@ class TSimpleRequest
268268
void Finish(const TOut& resp, ui32 status) {
269269
auto makeResponseString = [&] {
270270
TString x;
271-
google::protobuf::TextFormat::Printer printer;
272-
printer.SetSingleLineMode(true);
273-
printer.PrintToString(resp, &x);
271+
if (NYdbGrpc::LogBodyEnabled) {
272+
google::protobuf::TextFormat::Printer printer;
273+
printer.SetSingleLineMode(true);
274+
printer.PrintToString(resp, &x);
275+
} else {
276+
x = "<hidden>";
277+
}
274278
return x;
275279
};
276280
LOG_DEBUG(ActorSystem, NKikimrServices::GRPC_SERVER, "[%p] issuing response Name# %s data# %s peer# %s", this,
@@ -303,9 +307,13 @@ class TSimpleRequest
303307
auto makeRequestString = [&] {
304308
TString resp;
305309
if (ok) {
306-
google::protobuf::TextFormat::Printer printer;
307-
printer.SetSingleLineMode(true);
308-
printer.PrintToString(Request, &resp);
310+
if (NYdbGrpc::LogBodyEnabled) {
311+
google::protobuf::TextFormat::Printer printer;
312+
printer.SetSingleLineMode(true);
313+
printer.PrintToString(Request, &resp);
314+
} else {
315+
resp = "<hidden>";
316+
}
309317
} else {
310318
resp = "<not ok>";
311319
}

ydb/core/grpc_streaming/grpc_streaming.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,13 @@ class TGRpcStreamingRequest final
350350
auto dumpResultText = [&] {
351351
TString text;
352352
if (status == NYdbGrpc::EQueueEventStatus::OK) {
353-
google::protobuf::TextFormat::Printer printer;
354-
printer.SetSingleLineMode(true);
355-
printer.PrintToString(ReadInProgress->Record, &text);
353+
if (NYdbGrpc::LogBodyEnabled) {
354+
google::protobuf::TextFormat::Printer printer;
355+
printer.SetSingleLineMode(true);
356+
printer.PrintToString(ReadInProgress->Record, &text);
357+
} else {
358+
text = "<hidden>";
359+
}
356360
} else {
357361
text = "<not ok>";
358362
}
@@ -402,9 +406,13 @@ class TGRpcStreamingRequest final
402406
bool Write(TOut&& message, const grpc::WriteOptions& options = { }, const grpc::Status* status = nullptr) {
403407
auto dumpMessageText = [&] {
404408
TString text;
405-
google::protobuf::TextFormat::Printer printer;
406-
printer.SetSingleLineMode(true);
407-
printer.PrintToString(message, &text);
409+
if (NYdbGrpc::LogBodyEnabled) {
410+
google::protobuf::TextFormat::Printer printer;
411+
printer.SetSingleLineMode(true);
412+
printer.PrintToString(message, &text);
413+
} else {
414+
text = "<hidden>";
415+
}
408416
return text;
409417
};
410418

ydb/library/grpc/server/logger.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
#include <library/cpp/logger/priority.h>
44

55
#include <util/generic/ptr.h>
6+
#include <util/system/env.h>
7+
68

79
namespace NYdbGrpc {
810

11+
static bool LogBodyEnabled = "BODY" == GetEnv("YDB_GRPC_SERVER_LOGGING");
12+
913
class TLogger: public TThrRefBase {
1014
protected:
1115
TLogger() = default;

0 commit comments

Comments
 (0)