[Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_set_log_function (#36844)

[Gpr_To_Absl_Logging] Migrating from gpr to absl logging - gpr_set_log_function

Adding a warning for users of gpr_set_log_function.

This function will be deleted soon.
https://github.com/grpc/proposal/pull/425

Other options considered ( and discarded )
1. Using DFATAL instead of ERROR. Discarded this because we still have one critical unit test to clean up before we delete gpr_set_log_function. This test will fail if we use DFATAL. EXPECT_DFATAL macro is not available to be used.
2. Considered making a new absl log sink , and then that log sink should have a function pointer with the same signature as gpr_log_func. This function pointer can be set from gpr_set_log_function. However if this custom function uses absl from within it, that will cause infinite recursion. Made me drop the idea.

Closes #36844

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36844 from tanvi-jagtap:assert_gpr_set_log_function 805de358a9
PiperOrigin-RevId: 641473969
pull/36800/head^2
Tanvi Jagtap 8 months ago committed by Copybara-Service
parent e6e2f1e1cb
commit cd595a8794
  1. 10
      src/core/util/log.cc

@ -185,6 +185,16 @@ void gpr_log_verbosity_init() {
}
void gpr_set_log_function(gpr_log_func f) {
LOG(ERROR)
<< "This function is in the process of being deprecated. Your "
"gpr_log_func will not work as expected. This is because only few "
"instances of gpr_log remain in our code base. All instances of "
"gpr_log will log via this custom function. Many of the gpr_log "
"statements have been converted to ABSL_LOG statements. These will "
"log to the default absl log sink. The gpr_set_log_function function "
"will be deleted in the next gRPC release. We strongly advice against "
"using this function. You may create a new absl LogSink with similar "
"functionality. gRFC: https://github.com/grpc/proposal/pull/425 ";
gpr_atm_no_barrier_store(&g_log_func, (gpr_atm)(f ? f : gpr_default_log));
}

Loading…
Cancel
Save