[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 ee92404c35
PiperOrigin-RevId: 644127489
pull/36953/head
Yash Tibrewal 5 months ago committed by Copybara-Service
parent 2e4efaf77a
commit 2e4e92bb87
  1. 2
      src/core/lib/config/config_vars.cc
  2. 2
      src/core/lib/config/config_vars.yaml
  3. 7
      src/core/util/log.cc
  4. 6
      tools/codegen/core/gen_config_vars.py

@ -26,7 +26,7 @@
#include "src/core/lib/config/load_config.h" #include "src/core/lib/config/load_config.h"
#ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING #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 #endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING
#ifdef GRPC_ENABLE_FORK_SUPPORT #ifdef GRPC_ENABLE_FORK_SUPPORT

@ -66,7 +66,7 @@
type: string type: string
prelude: | prelude: |
#ifndef GPR_DEFAULT_LOG_VERBOSITY_STRING #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 #endif // !GPR_DEFAULT_LOG_VERBOSITY_STRING
default: $GPR_DEFAULT_LOG_VERBOSITY_STRING default: $GPR_DEFAULT_LOG_VERBOSITY_STRING
description: description:

@ -35,10 +35,6 @@
#include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/crash.h"
#include "src/core/util/string.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_UNSET = GPR_LOG_SEVERITY_ERROR + 10;
static constexpr gpr_atm GPR_LOG_SEVERITY_NONE = GPR_LOG_SEVERITY_ERROR + 11; 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")) { } else if (absl::EqualsIgnoreCase(verbosity, "NONE")) {
absl::SetVLogLevel("*grpc*/*", -1); absl::SetVLogLevel("*grpc*/*", -1);
absl::SetMinLogLevel(absl::LogSeverityAtLeast::kInfinity); 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 { } else {
LOG(ERROR) << "Unknown log verbosity: " << verbosity; LOG(ERROR) << "Unknown log verbosity: " << verbosity;
} }

@ -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("#ifndef GRPC_TEST_CORE_TEST_UTIL_FUZZ_CONFIG_VARS_H", file=H)
print("#define GRPC_TEST_CORE_UTIL_FUZZ_CONFIG_VARS_H", file=H) print("#define GRPC_TEST_CORE_TEST_UTIL_FUZZ_CONFIG_VARS_H", file=H)
print(file=H) print(file=H)
print("#include <grpc/support/port_platform.h>", file=H) print("#include <grpc/support/port_platform.h>", file=H)
print(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(file=H)
print("} // namespace grpc_core", file=H) print("} // namespace grpc_core", file=H)
print(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: with open("test/core/test_util/fuzz_config_vars.cc", "w") as C:
put_copyright(C) put_copyright(C)

Loading…
Cancel
Save