From 3a05c56060af41d7e68971ee61306aec1d2eb709 Mon Sep 17 00:00:00 2001 From: Nikolay Shestakov Date: Wed, 6 Mar 2024 15:23:11 +0000 Subject: [PATCH] fix --- ydb/core/client/server/grpc_server.cpp | 9 ++------- ydb/core/grpc_streaming/grpc_streaming.h | 20 ++++++++++++++------ ydb/library/grpc/server/logger.h | 4 ++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/ydb/core/client/server/grpc_server.cpp b/ydb/core/client/server/grpc_server.cpp index e4436176558c..6eeedc44d2f1 100644 --- a/ydb/core/client/server/grpc_server.cpp +++ b/ydb/core/client/server/grpc_server.cpp @@ -10,7 +10,6 @@ #include #include -#include #include @@ -79,8 +78,6 @@ class TSimpleRequest , InProgress_(false) { LOG_DEBUG(ActorSystem, NKikimrServices::GRPC_SERVER, "[%p] created request Name# %s", this, Name); - - LogBody = "BODY" == GetEnv("YDB_LOGGING"); } ~TSimpleRequest() { @@ -271,7 +268,7 @@ class TSimpleRequest void Finish(const TOut& resp, ui32 status) { auto makeResponseString = [&] { TString x; - if (LogBody) { + if (NYdbGrpc::LogBodyEnabled) { google::protobuf::TextFormat::Printer printer; printer.SetSingleLineMode(true); printer.PrintToString(resp, &x); @@ -310,7 +307,7 @@ class TSimpleRequest auto makeRequestString = [&] { TString resp; if (ok) { - if (LogBody) { + if (NYdbGrpc::LogBodyEnabled) { google::protobuf::TextFormat::Printer printer; printer.SetSingleLineMode(true); printer.PrintToString(Request, &resp); @@ -403,8 +400,6 @@ class TSimpleRequest bool RequestDestroyed_ = false; bool CallInProgress_ = false; bool Finished_ = false; - - bool LogBody; }; } // namespace diff --git a/ydb/core/grpc_streaming/grpc_streaming.h b/ydb/core/grpc_streaming/grpc_streaming.h index 872ab75bda76..5e95413f7205 100644 --- a/ydb/core/grpc_streaming/grpc_streaming.h +++ b/ydb/core/grpc_streaming/grpc_streaming.h @@ -350,9 +350,13 @@ class TGRpcStreamingRequest final auto dumpResultText = [&] { TString text; if (status == NYdbGrpc::EQueueEventStatus::OK) { - google::protobuf::TextFormat::Printer printer; - printer.SetSingleLineMode(true); - printer.PrintToString(ReadInProgress->Record, &text); + if (NYdbGrpc::LogBodyEnabled) { + google::protobuf::TextFormat::Printer printer; + printer.SetSingleLineMode(true); + printer.PrintToString(ReadInProgress->Record, &text); + } else { + text = ""; + } } else { text = ""; } @@ -402,9 +406,13 @@ class TGRpcStreamingRequest final bool Write(TOut&& message, const grpc::WriteOptions& options = { }, const grpc::Status* status = nullptr) { auto dumpMessageText = [&] { TString text; - google::protobuf::TextFormat::Printer printer; - printer.SetSingleLineMode(true); - printer.PrintToString(message, &text); + if (NYdbGrpc::LogBodyEnabled) { + google::protobuf::TextFormat::Printer printer; + printer.SetSingleLineMode(true); + printer.PrintToString(message, &text); + } else { + text = ""; + } return text; }; diff --git a/ydb/library/grpc/server/logger.h b/ydb/library/grpc/server/logger.h index 1460afa09633..fb6afc8be808 100644 --- a/ydb/library/grpc/server/logger.h +++ b/ydb/library/grpc/server/logger.h @@ -3,9 +3,13 @@ #include #include +#include + namespace NYdbGrpc { +static bool LogBodyEnabled = "BODY" == GetEnv("YDB_GRPC_SERVER_LOGGING"); + class TLogger: public TThrRefBase { protected: TLogger() = default;