diff --git a/grpc.def b/grpc.def index ddc6440f34f77..4820cf1421394 100644 --- a/grpc.def +++ b/grpc.def @@ -231,7 +231,7 @@ EXPORTS gpr_cpu_num_cores gpr_cpu_current_cpu gpr_log - gpr_should_log + absl_vlog2_enabled gpr_log_verbosity_init gpr_format_message gpr_strdup diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h index 88e7628e0cc5c..82e64a8c56f21 100644 --- a/include/grpc/support/log.h +++ b/include/grpc/support/log.h @@ -51,7 +51,8 @@ typedef enum gpr_log_severity { GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5); -GPRAPI int gpr_should_log(gpr_log_severity severity); +/** Deprecated. **/ +GPRAPI int absl_vlog2_enabled(); GPRAPI void gpr_log_verbosity_init(void); diff --git a/src/core/ext/transport/binder/wire_format/wire_writer.cc b/src/core/ext/transport/binder/wire_format/wire_writer.cc index 65724a432973b..1b954e1d26a9f 100644 --- a/src/core/ext/transport/binder/wire_format/wire_writer.cc +++ b/src/core/ext/transport/binder/wire_format/wire_writer.cc @@ -377,7 +377,7 @@ void WireWriterImpl::TryScheduleTransaction() { } else { // It is common to fill `kFlowControlWindowSize` completely because // transactions are send at faster rate than the other end of transport - // can handle it, so here we use `GPR_DEBUG` log level. + // can handle it, so here we use VLOG(2). VLOG(2) << "Some work cannot be scheduled yet due to slow ack from the " "other end of transport. This transport might be blocked if " "this number don't go down. pending_outgoing_tx_.size() = " diff --git a/src/core/util/android/log.cc b/src/core/util/android/log.cc index 942ac4bd2ffb5..967000490da96 100644 --- a/src/core/util/android/log.cc +++ b/src/core/util/android/log.cc @@ -30,6 +30,7 @@ #include "src/core/lib/gprpp/crash.h" +extern int gpr_should_log(gpr_log_severity severity); extern void gpr_log_message(const char* file, int line, gpr_log_severity severity, const char* message); diff --git a/src/core/util/linux/log.cc b/src/core/util/linux/log.cc index bede7c8c21931..108ff3cb4e708 100644 --- a/src/core/util/linux/log.cc +++ b/src/core/util/linux/log.cc @@ -47,6 +47,7 @@ #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/examine_stack.h" +extern int gpr_should_log(gpr_log_severity severity); extern void gpr_log_message(const char* file, int line, gpr_log_severity severity, const char* message); diff --git a/src/core/util/log.cc b/src/core/util/log.cc index 411f76a14cd54..c34c1503d3c6d 100644 --- a/src/core/util/log.cc +++ b/src/core/util/log.cc @@ -40,6 +40,8 @@ void gpr_unreachable_code(const char* reason, const char* file, int line) { grpc_core::SourceLocation(file, line)); } +int absl_vlog2_enabled() { return ABSL_VLOG_IS_ON(2); } + int gpr_should_log(gpr_log_severity severity) { switch (severity) { case GPR_LOG_SEVERITY_ERROR: diff --git a/src/core/util/posix/log.cc b/src/core/util/posix/log.cc index 2d1fe2ebb65f6..abd7dfe604318 100644 --- a/src/core/util/posix/log.cc +++ b/src/core/util/posix/log.cc @@ -38,6 +38,7 @@ #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/examine_stack.h" +extern int gpr_should_log(gpr_log_severity severity); extern void gpr_log_message(const char* file, int line, gpr_log_severity severity, const char* message); diff --git a/src/core/util/windows/log.cc b/src/core/util/windows/log.cc index e3c7b1179fe4f..c5b764032a3d7 100644 --- a/src/core/util/windows/log.cc +++ b/src/core/util/windows/log.cc @@ -33,6 +33,7 @@ #include "src/core/lib/gprpp/examine_stack.h" #include "src/core/util/string.h" +extern int gpr_should_log(gpr_log_severity severity); extern void gpr_log_message(const char* file, int line, gpr_log_severity severity, const char* message); diff --git a/src/ruby/ext/grpc/rb_call_credentials.c b/src/ruby/ext/grpc/rb_call_credentials.c index 1afcfbdcc74d1..9689942bc2bc2 100644 --- a/src/ruby/ext/grpc/rb_call_credentials.c +++ b/src/ruby/ext/grpc/rb_call_credentials.c @@ -60,7 +60,7 @@ static VALUE grpc_rb_call_credentials_callback(VALUE args) { VALUE callback_func = rb_ary_entry(args, 0); VALUE callback_args = rb_ary_entry(args, 1); VALUE md_ary_obj = rb_ary_entry(args, 2); - if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) { + if (absl_vlog2_enabled()) { VALUE callback_func_str = rb_funcall(callback_func, rb_intern("to_s"), 0); VALUE callback_args_str = rb_funcall(callback_args, rb_intern("to_s"), 0); VALUE callback_source_info = diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index b0cfa9ce6b052..36e66f82b8684 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -254,7 +254,7 @@ gpr_free_aligned_type gpr_free_aligned_import; gpr_cpu_num_cores_type gpr_cpu_num_cores_import; gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; gpr_log_type gpr_log_import; -gpr_should_log_type gpr_should_log_import; +absl_vlog2_enabled_type absl_vlog2_enabled_import; gpr_log_verbosity_init_type gpr_log_verbosity_init_import; gpr_format_message_type gpr_format_message_import; gpr_strdup_type gpr_strdup_import; @@ -539,7 +539,7 @@ void grpc_rb_load_imports(HMODULE library) { gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores"); gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu"); gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log"); - gpr_should_log_import = (gpr_should_log_type) GetProcAddress(library, "gpr_should_log"); + absl_vlog2_enabled_import = (absl_vlog2_enabled_type) GetProcAddress(library, "absl_vlog2_enabled"); gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init"); gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message"); gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 1b325a1a024d6..8ddd62a7ce9c1 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -738,9 +738,9 @@ extern gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; typedef void(*gpr_log_type)(const char* file, int line, gpr_log_severity severity, const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5); extern gpr_log_type gpr_log_import; #define gpr_log gpr_log_import -typedef int(*gpr_should_log_type)(gpr_log_severity severity); -extern gpr_should_log_type gpr_should_log_import; -#define gpr_should_log gpr_should_log_import +typedef int(*absl_vlog2_enabled_type)(); +extern absl_vlog2_enabled_type absl_vlog2_enabled_import; +#define absl_vlog2_enabled absl_vlog2_enabled_import typedef void(*gpr_log_verbosity_init_type)(void); extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import; #define gpr_log_verbosity_init gpr_log_verbosity_init_import diff --git a/tools/run_tests/sanity/banned_functions.py b/tools/run_tests/sanity/banned_functions.py index df6084a10a02b..06a330eaa78c8 100755 --- a/tools/run_tests/sanity/banned_functions.py +++ b/tools/run_tests/sanity/banned_functions.py @@ -37,6 +37,11 @@ # Map of deprecated functions to allowlist files DEPRECATED_FUNCTION_TEMP_ALLOW_LIST = { + "absl_vlog2_enabled(": [ + "./include/grpc/support/log.h", + "./src/core/util/log.cc", + "./src/ruby/ext/grpc/rb_call_credentials.c", + ], "gpr_log_severity": [ "./include/grpc/support/log.h", "./src/core/util/android/log.cc", @@ -63,13 +68,11 @@ "./src/ruby/ext/grpc/rb_server.c", ], "gpr_should_log(": [ - "./include/grpc/support/log.h", "./src/core/util/android/log.cc", "./src/core/util/linux/log.cc", "./src/core/util/log.cc", "./src/core/util/posix/log.cc", "./src/core/util/windows/log.cc", - "./src/ruby/ext/grpc/rb_call_credentials.c", ], "gpr_log_message(": [ "./src/core/util/android/log.cc",