Skip to content

Commit 3a05c56

Browse files
committed
fix
1 parent f93aa1b commit 3a05c56

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

ydb/core/client/server/grpc_server.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <library/cpp/json/json_writer.h>
1111

1212
#include <util/string/join.h>
13-
#include <util/system/env.h>
1413

1514
#include <google/protobuf/text_format.h>
1615

@@ -79,8 +78,6 @@ class TSimpleRequest
7978
, InProgress_(false)
8079
{
8180
LOG_DEBUG(ActorSystem, NKikimrServices::GRPC_SERVER, "[%p] created request Name# %s", this, Name);
82-
83-
LogBody = "BODY" == GetEnv("YDB_LOGGING");
8481
}
8582

8683
~TSimpleRequest() {
@@ -271,7 +268,7 @@ class TSimpleRequest
271268
void Finish(const TOut& resp, ui32 status) {
272269
auto makeResponseString = [&] {
273270
TString x;
274-
if (LogBody) {
271+
if (NYdbGrpc::LogBodyEnabled) {
275272
google::protobuf::TextFormat::Printer printer;
276273
printer.SetSingleLineMode(true);
277274
printer.PrintToString(resp, &x);
@@ -310,7 +307,7 @@ class TSimpleRequest
310307
auto makeRequestString = [&] {
311308
TString resp;
312309
if (ok) {
313-
if (LogBody) {
310+
if (NYdbGrpc::LogBodyEnabled) {
314311
google::protobuf::TextFormat::Printer printer;
315312
printer.SetSingleLineMode(true);
316313
printer.PrintToString(Request, &resp);
@@ -403,8 +400,6 @@ class TSimpleRequest
403400
bool RequestDestroyed_ = false;
404401
bool CallInProgress_ = false;
405402
bool Finished_ = false;
406-
407-
bool LogBody;
408403
};
409404

410405
} // namespace

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)