From f51793258a813cca1fd0873b81d0c562183cae80 Mon Sep 17 00:00:00 2001 From: Mauro Ezequiel Moltrasio Date: Mon, 7 Apr 2025 11:06:27 +0200 Subject: [PATCH] Prevent serialization in LogProtobufMessage if log level is not met --- collector/lib/Utility.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/collector/lib/Utility.cpp b/collector/lib/Utility.cpp index deb98e4364..92f0a0b03a 100644 --- a/collector/lib/Utility.cpp +++ b/collector/lib/Utility.cpp @@ -254,6 +254,11 @@ std::optional SanitizedUTF8(std::string_view str) { void LogProtobufMessage(const google::protobuf::Message& msg) { using namespace google::protobuf::util; + + if (!logging::CheckLogLevel(logging::LogLevel::DEBUG)) { + return; + } + std::string output; absl::Status status = MessageToJsonString(msg, &output, JsonPrintOptions{}); if (status.ok()) {