diff --git a/grpc.def b/grpc.def index 6679a51c5ca..71a6713691c 100644 --- a/grpc.def +++ b/grpc.def @@ -232,7 +232,6 @@ EXPORTS gpr_cpu_current_cpu gpr_log gpr_should_log - gpr_log_message gpr_set_log_verbosity gpr_log_verbosity_init gpr_set_log_function diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h index 7df1969f1b2..cb7ae07431f 100644 --- a/include/grpc/support/log.h +++ b/include/grpc/support/log.h @@ -53,9 +53,6 @@ GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity, GPRAPI int gpr_should_log(gpr_log_severity severity); -GPRAPI void gpr_log_message(const char* file, int line, - gpr_log_severity severity, const char* message); - /** Set global log verbosity */ GPRAPI void gpr_set_log_verbosity(gpr_log_severity deprecated_setting); diff --git a/src/core/util/android/log.cc b/src/core/util/android/log.cc index aeb2dc4b26c..942ac4bd2ff 100644 --- a/src/core/util/android/log.cc +++ b/src/core/util/android/log.cc @@ -30,6 +30,9 @@ #include "src/core/lib/gprpp/crash.h" +extern void gpr_log_message(const char* file, int line, + gpr_log_severity severity, const char* message); + void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) { // Avoid message construction if gpr_log_message won't log diff --git a/src/core/util/linux/log.cc b/src/core/util/linux/log.cc index f09ecb2dbbc..bede7c8c219 100644 --- a/src/core/util/linux/log.cc +++ b/src/core/util/linux/log.cc @@ -47,6 +47,9 @@ #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/examine_stack.h" +extern void gpr_log_message(const char* file, int line, + gpr_log_severity severity, const char* message); + void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) { // Avoid message construction if gpr_log_message won't log diff --git a/src/core/util/log.cc b/src/core/util/log.cc index f473f692071..ca89ba97a99 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" -void gpr_default_log(gpr_log_func_args* args); -void gpr_platform_log(gpr_log_func_args* args); -static gpr_atm g_log_func = reinterpret_cast(gpr_default_log); - void gpr_unreachable_code(const char* reason, const char* file, int line) { grpc_core::Crash(absl::StrCat("UNREACHABLE CODE: ", reason), grpc_core::SourceLocation(file, line)); @@ -63,40 +59,29 @@ int gpr_should_log(gpr_log_severity severity) { } } -void gpr_default_log(gpr_log_func_args* args) { - switch (args->severity) { +void gpr_log_message(const char* file, int line, gpr_log_severity severity, + const char* message) { + if (gpr_should_log(severity) == 0) { + return; + } + switch (severity) { case GPR_LOG_SEVERITY_DEBUG: // Log DEBUG messages as VLOG(2). - VLOG(2).AtLocation(args->file, args->line) << args->message; + VLOG(2).AtLocation(file, line) << message; return; case GPR_LOG_SEVERITY_INFO: - LOG(INFO).AtLocation(args->file, args->line) << args->message; + LOG(INFO).AtLocation(file, line) << message; return; case GPR_LOG_SEVERITY_ERROR: - LOG(ERROR).AtLocation(args->file, args->line) << args->message; + LOG(ERROR).AtLocation(file, line) << message; return; default: - LOG(ERROR) << __func__ << ": unknown gpr log severity(" << args->severity + LOG(ERROR) << __func__ << ": unknown gpr log severity(" << severity << "), using ERROR"; - LOG(ERROR).AtLocation(args->file, args->line) << args->message; + LOG(ERROR).AtLocation(file, line) << message; } } -void gpr_log_message(const char* file, int line, gpr_log_severity severity, - const char* message) { - if (gpr_should_log(severity) == 0) { - return; - } - - gpr_log_func_args lfargs; - memset(&lfargs, 0, sizeof(lfargs)); - lfargs.file = file; - lfargs.line = line; - lfargs.severity = severity; - lfargs.message = message; - reinterpret_cast(gpr_atm_no_barrier_load(&g_log_func))(&lfargs); -} - void gpr_set_log_verbosity( [[maybe_unused]] gpr_log_severity deprecated_setting) { LOG(ERROR) diff --git a/src/core/util/posix/log.cc b/src/core/util/posix/log.cc index 09791014ef8..2d1fe2ebb65 100644 --- a/src/core/util/posix/log.cc +++ b/src/core/util/posix/log.cc @@ -38,6 +38,9 @@ #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/examine_stack.h" +extern void gpr_log_message(const char* file, int line, + gpr_log_severity severity, const char* message); + void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) { // Avoid message construction if gpr_log_message won't log diff --git a/src/core/util/windows/log.cc b/src/core/util/windows/log.cc index 722e4bd9a83..e3c7b1179fe 100644 --- a/src/core/util/windows/log.cc +++ b/src/core/util/windows/log.cc @@ -33,6 +33,9 @@ #include "src/core/lib/gprpp/examine_stack.h" #include "src/core/util/string.h" +extern void gpr_log_message(const char* file, int line, + gpr_log_severity severity, const char* message); + void gpr_log(const char* file, int line, gpr_log_severity severity, const char* format, ...) { // Avoid message construction if gpr_log_message won't log diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index 4bb5d2a91c9..fd7a37049cb 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -255,7 +255,6 @@ 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; -gpr_log_message_type gpr_log_message_import; gpr_set_log_verbosity_type gpr_set_log_verbosity_import; gpr_log_verbosity_init_type gpr_log_verbosity_init_import; gpr_set_log_function_type gpr_set_log_function_import; @@ -543,7 +542,6 @@ void grpc_rb_load_imports(HMODULE library) { 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"); - gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message"); gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity"); gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init"); gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 36074841258..a1989a75465 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -741,9 +741,6 @@ extern gpr_log_type 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 void(*gpr_log_message_type)(const char* file, int line, gpr_log_severity severity, const char* message); -extern gpr_log_message_type gpr_log_message_import; -#define gpr_log_message gpr_log_message_import typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity deprecated_setting); extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import; #define gpr_set_log_verbosity gpr_set_log_verbosity_import