From 2e4e92bb87718c43e53bf7fa31223956b586dc9a Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 17 Jun 2024 14:05:47 -0700 Subject: [PATCH] [log] Do not set absl min log level if user does not set GRPC_VERBOSITY (#36931) Do not set `absl::MinLogLevel` if user does not set `GRPC_VERBOSITY`. Only set `absl::MinLogLevel` if the user has specified `GRPC_VERBOSITY`. Background: gRPC Core overrides the setting of `absl::MinLogLevel` based on the setting of `GRPC_VERBOSITY`. `GRPC_VERBOSITY` defaults to the setting of `GPR_DEFAULT_LOG_VERBOSITY_STRING` if that env var is not set, resulting in the consequence that gRPC Core would override the setting of `absl::MinLogLevel` even if the user had previously modified it. Note that even with this change, the minimum log severity that's printed remains at `ERROR` by default. Closes #36931 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36931 from yashykt:ChangeDefaultGrpcVerbosity ee92404c35bad2886396681ca2f0f729fed4a4b7 PiperOrigin-RevId: 644127489 --- src/core/lib/config/config_vars.cc | 2 +- src/core/lib/config/config_vars.yaml | 2 +- src/core/util/log.cc | 7 +++---- tools/codegen/core/gen_config_vars.py | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/core/lib/config/config_vars.cc b/src/core/lib/config/config_vars.cc index b3a919b1170..c67f4463f0c 100644 --- a/src/core/lib/config/config_vars.cc +++ b/src/core/lib/config/config_vars.cc @@ -26,7 +26,7 @@ #include "src/core/lib/config/load_config.h" #ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING -#define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR" +#define GPR_DEFAULT_LOG_VERBOSITY_STRING "" #endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING #ifdef GRPC_ENABLE_FORK_SUPPORT diff --git a/src/core/lib/config/config_vars.yaml b/src/core/lib/config/config_vars.yaml index 56e0e25d302..afedf2f7b9c 100644 --- a/src/core/lib/config/config_vars.yaml +++ b/src/core/lib/config/config_vars.yaml @@ -66,7 +66,7 @@ type: string prelude: | #ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING - #define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR" + #define GPR_DEFAULT_LOG_VERBOSITY_STRING "" #endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING default: $GPR_DEFAULT_LOG_VERBOSITY_STRING description: diff --git a/src/core/util/log.cc b/src/core/util/log.cc index 792fee6c550..4518f9eec0e 100644 --- a/src/core/util/log.cc +++ b/src/core/util/log.cc @@ -35,10 +35,6 @@ #include "src/core/lib/gprpp/crash.h" #include "src/core/util/string.h" -#ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING -#define GPR_DEFAULT_LOG_VERBOSITY_STRING "ERROR" -#endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING - static constexpr gpr_atm GPR_LOG_SEVERITY_UNSET = GPR_LOG_SEVERITY_ERROR + 10; static constexpr gpr_atm GPR_LOG_SEVERITY_NONE = GPR_LOG_SEVERITY_ERROR + 11; @@ -145,6 +141,9 @@ void gpr_to_absl_verbosity_setting_init(void) { } else if (absl::EqualsIgnoreCase(verbosity, "NONE")) { absl::SetVLogLevel("*grpc*/*", -1); absl::SetMinLogLevel(absl::LogSeverityAtLeast::kInfinity); + } else if (verbosity.empty()) { + // Do not set absl::MinLogLevel if verbosity has not been set. Note that the + // default gRPC min log severity that is printed will still be ERROR. } else { LOG(ERROR) << "Unknown log verbosity: " << verbosity; } diff --git a/tools/codegen/core/gen_config_vars.py b/tools/codegen/core/gen_config_vars.py index c2c46fa4338..1aa217a3ee3 100755 --- a/tools/codegen/core/gen_config_vars.py +++ b/tools/codegen/core/gen_config_vars.py @@ -219,8 +219,8 @@ with open("test/core/test_util/fuzz_config_vars.h", "w") as H: ], ) - print("#ifndef GRPC_TEST_CORE_UTIL_FUZZ_CONFIG_VARS_H", file=H) - print("#define GRPC_TEST_CORE_UTIL_FUZZ_CONFIG_VARS_H", file=H) + print("#ifndef GRPC_TEST_CORE_TEST_UTIL_FUZZ_CONFIG_VARS_H", file=H) + print("#define GRPC_TEST_CORE_TEST_UTIL_FUZZ_CONFIG_VARS_H", file=H) print(file=H) print("#include ", file=H) print(file=H) @@ -243,7 +243,7 @@ with open("test/core/test_util/fuzz_config_vars.h", "w") as H: print(file=H) print("} // namespace grpc_core", file=H) print(file=H) - print("#endif // GRPC_TEST_CORE_UTIL_FUZZ_CONFIG_VARS_H", file=H) + print("#endif // GRPC_TEST_CORE_TEST_UTIL_FUZZ_CONFIG_VARS_H", file=H) with open("test/core/test_util/fuzz_config_vars.cc", "w") as C: put_copyright(C)