Skip to content

Commit

Permalink
Sync c-core 1.65.0-pre2
Browse files Browse the repository at this point in the history
  • Loading branch information
HannahShiSFB committed Jun 25, 2024
1 parent 5d79a3c commit 7a21c14
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 85 deletions.
2 changes: 1 addition & 1 deletion gRPC-C++.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-C++'
# TODO (mxyan): use version that match gRPC version when pod is stabilized
version = '1.65.0-pre1'
version = '1.65.0-pre2'
s.version = version
s.summary = 'gRPC C++ library'
s.homepage = 'https://grpc.io'
Expand Down
2 changes: 1 addition & 1 deletion gRPC-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

Pod::Spec.new do |s|
s.name = 'gRPC-Core'
version = '1.65.0-pre1'
version = '1.65.0-pre2'
s.version = version
s.summary = 'Core cross-platform gRPC library, written in C'
s.homepage = 'https://grpc.io'
Expand Down
2 changes: 1 addition & 1 deletion gRPC-ProtoRPC.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

Pod::Spec.new do |s|
s.name = 'gRPC-ProtoRPC'
version = '1.65.0-pre1'
version = '1.65.0-pre2'
s.version = version
s.summary = 'RPC library for Protocol Buffers, based on gRPC'
s.homepage = 'https://grpc.io'
Expand Down
2 changes: 1 addition & 1 deletion gRPC-RxLibrary.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

Pod::Spec.new do |s|
s.name = 'gRPC-RxLibrary'
version = '1.65.0-pre1'
version = '1.65.0-pre2'
s.version = version
s.summary = 'Reactive Extensions library for iOS/OSX.'
s.homepage = 'https://grpc.io'
Expand Down
2 changes: 1 addition & 1 deletion gRPC.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

Pod::Spec.new do |s|
s.name = 'gRPC'
version = '1.65.0-pre1'
version = '1.65.0-pre2'
s.version = version
s.summary = 'gRPC client library for iOS/OSX'
s.homepage = 'https://grpc.io'
Expand Down
17 changes: 6 additions & 11 deletions include/grpc/support/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@
extern "C" {
#endif

/** GPR log API.
Usage (within grpc):
int argument1 = 3;
char* argument2 = "hello";
gpr_log(GPR_DEBUG, "format string %d", argument1);
gpr_log(GPR_INFO, "hello world");
gpr_log(GPR_ERROR, "%d %s!!", argument1, argument2); */
/**
* Logging functions in this file are deprecated.
* Please use absl ABSL_LOG instead.
*/

/** The severity of a log message - use the #defines below when calling into
gpr_log to additionally supply file and line data */
Expand Down Expand Up @@ -65,7 +60,7 @@ 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 min_severity_to_print);
GPRAPI void gpr_set_log_verbosity(gpr_log_severity deprecated_setting);

GPRAPI void gpr_log_verbosity_init(void);

Expand All @@ -83,7 +78,7 @@ typedef struct gpr_log_func_args gpr_log_func_args;

typedef void (*gpr_log_func)(gpr_log_func_args* args);

GPRAPI void gpr_set_log_function(gpr_log_func func);
GPRAPI void gpr_set_log_function(gpr_log_func deprecated_setting);

GPRAPI void gpr_assertion_failed(const char* filename, int line,
const char* message) GPR_ATTRIBUTE_NORETURN;
Expand Down
4 changes: 2 additions & 2 deletions include/grpcpp/version_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define GRPC_CPP_VERSION_MAJOR 1
#define GRPC_CPP_VERSION_MINOR 65
#define GRPC_CPP_VERSION_PATCH 0
#define GRPC_CPP_VERSION_TAG "pre1"
#define GRPC_CPP_VERSION_STRING "1.65.0-pre1"
#define GRPC_CPP_VERSION_TAG "pre2"
#define GRPC_CPP_VERSION_STRING "1.65.0-pre2"

#endif // GRPCPP_VERSION_INFO_H
2 changes: 1 addition & 1 deletion src/core/lib/config/config_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
92 changes: 29 additions & 63 deletions src/core/util/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,9 @@
#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;

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_atm>(gpr_default_log);
static gpr_atm g_min_severity_to_print = GPR_LOG_SEVERITY_UNSET;
static gpr_atm g_min_severity_to_print_stacktrace = GPR_LOG_SEVERITY_UNSET;

void gpr_unreachable_code(const char* reason, const char* file, int line) {
grpc_core::Crash(absl::StrCat("UNREACHABLE CODE: ", reason),
Expand All @@ -71,10 +62,22 @@ const char* gpr_log_severity_string(gpr_log_severity severity) {
}

int gpr_should_log(gpr_log_severity severity) {
return static_cast<gpr_atm>(severity) >=
gpr_atm_no_barrier_load(&g_min_severity_to_print)
? 1
: 0;
switch (severity) {
case GPR_LOG_SEVERITY_ERROR:
return absl::MinLogLevel() <= absl::LogSeverityAtLeast::kError;
case GPR_LOG_SEVERITY_INFO:
// There is no documentation about how expensive or inexpensive
// MinLogLevel is. We could have saved this in a static const variable.
// But decided against it just in case anyone programatically sets absl
// min log level settings after this has been initialized.
// Same holds for VLOG_IS_ON(2).
return absl::MinLogLevel() <= absl::LogSeverityAtLeast::kInfo;
case GPR_LOG_SEVERITY_DEBUG:
return VLOG_IS_ON(2);
default:
DLOG(ERROR) << "Invalid gpr_log_severity.";
return true;
}
}

void gpr_default_log(gpr_log_func_args* args) {
Expand Down Expand Up @@ -111,25 +114,21 @@ void gpr_log_message(const char* file, int line, gpr_log_severity severity,
reinterpret_cast<gpr_log_func>(gpr_atm_no_barrier_load(&g_log_func))(&lfargs);
}

void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) {
gpr_atm_no_barrier_store(&g_min_severity_to_print,
(gpr_atm)min_severity_to_print);
}

static gpr_atm parse_log_severity(absl::string_view str, gpr_atm error_value) {
if (absl::EqualsIgnoreCase(str, "DEBUG")) return GPR_LOG_SEVERITY_DEBUG;
if (absl::EqualsIgnoreCase(str, "INFO")) return GPR_LOG_SEVERITY_INFO;
if (absl::EqualsIgnoreCase(str, "ERROR")) return GPR_LOG_SEVERITY_ERROR;
if (absl::EqualsIgnoreCase(str, "NONE")) return GPR_LOG_SEVERITY_NONE;
return error_value;
void gpr_set_log_verbosity(
[[maybe_unused]] gpr_log_severity deprecated_setting) {
LOG(ERROR)
<< "This will not be set. Please set this via absl log level settings.";
}

void gpr_to_absl_verbosity_setting_init(void) {
void gpr_log_verbosity_init(void) {
// This is enabled in Github only.
// This ifndef is converted to ifdef internally by copybara.
// Internally grpc verbosity is managed using absl settings.
// So internally we avoid setting it like this.
#ifndef GRPC_VERBOSITY_MACRO
// SetMinLogLevel sets the value for the entire binary, not just gRPC.
// This setting will change things for other libraries/code that is unrelated
// to grpc.
absl::string_view verbosity = grpc_core::ConfigVars::Get().Verbosity();
DVLOG(2) << "Log verbosity: " << verbosity;
if (absl::EqualsIgnoreCase(verbosity, "INFO")) {
Expand All @@ -150,50 +149,17 @@ 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 alter absl settings if GRPC_VERBOSITY flag is not set.
} else {
LOG(ERROR) << "Unknown log verbosity: " << verbosity;
}
#endif // GRPC_VERBOSITY_MACRO
}

void gpr_log_verbosity_init() {
// init verbosity when it hasn't been set
if ((gpr_atm_no_barrier_load(&g_min_severity_to_print)) ==
GPR_LOG_SEVERITY_UNSET) {
auto verbosity = grpc_core::ConfigVars::Get().Verbosity();
gpr_atm min_severity_to_print = GPR_LOG_SEVERITY_ERROR;
if (!verbosity.empty()) {
min_severity_to_print =
parse_log_severity(verbosity, min_severity_to_print);
}
gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print);
}
// init stacktrace_minloglevel when it hasn't been set
if ((gpr_atm_no_barrier_load(&g_min_severity_to_print_stacktrace)) ==
GPR_LOG_SEVERITY_UNSET) {
auto stacktrace_minloglevel =
grpc_core::ConfigVars::Get().StacktraceMinloglevel();
gpr_atm min_severity_to_print_stacktrace = GPR_LOG_SEVERITY_NONE;
if (!stacktrace_minloglevel.empty()) {
min_severity_to_print_stacktrace = parse_log_severity(
stacktrace_minloglevel, min_severity_to_print_stacktrace);
}
gpr_atm_no_barrier_store(&g_min_severity_to_print_stacktrace,
min_severity_to_print_stacktrace);
}
gpr_to_absl_verbosity_setting_init();
}

void gpr_set_log_function(gpr_log_func f) {
void gpr_set_log_function([[maybe_unused]] gpr_log_func deprecated_setting) {
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 "
<< "This function is deprecated. This function will be deleted in the "
"next gRPC release. 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));
}
2 changes: 1 addition & 1 deletion src/objective-c/!ProtoCompiler-gRPCCppPlugin.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Pod::Spec.new do |s|
# exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
# before them.
s.name = '!ProtoCompiler-gRPCCppPlugin'
v = '1.65.0-pre1'
v = '1.65.0-pre2'
s.version = v
s.summary = 'The gRPC ProtoC plugin generates C++ files from .proto services.'
s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Pod::Spec.new do |s|
# exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
# before them.
s.name = '!ProtoCompiler-gRPCPlugin'
v = '1.65.0-pre1'
v = '1.65.0-pre2'
s.version = v
s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.'
s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion src/objective-c/GRPCClient/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
// instead. This file can be regenerated from the template by running
// `tools/buildgen/generate_projects.sh`.

#define GRPC_OBJC_VERSION_STRING @"1.65.0-pre1"
#define GRPC_OBJC_VERSION_STRING @"1.65.0-pre2"

0 comments on commit 7a21c14

Please sign in to comment.