Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L117: C-core: replace gpr logging with absl logging #425

Merged
merged 26 commits into from May 17, 2024
Merged
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f730a07
gRFC for gpr logging to absl logging
tanvi-jagtap Apr 17, 2024
4c5a3ad
Fixing typo
tanvi-jagtap Apr 17, 2024
f05ebe0
Fixing typo
tanvi-jagtap Apr 17, 2024
5bc4021
Fixing the links
tanvi-jagtap Apr 17, 2024
d942b49
Adding details about verbosity
tanvi-jagtap Apr 19, 2024
4f85d1b
Adding proposed behaviour
tanvi-jagtap Apr 19, 2024
f61ba63
Rename L115-replacing-gpr-logging-with-abseil-logging.md to L116-repl…
tanvi-jagtap Apr 24, 2024
09a2281
Rename L116-replacing-gpr-logging-with-abseil-logging.md to L116-cpp-…
tanvi-jagtap Apr 25, 2024
3cc42fc
Update L116-cpp-replacing-gpr-logging-with-abseil-logging.md
tanvi-jagtap Apr 25, 2024
55a71a4
Rename L116-cpp-replacing-gpr-logging-with-abseil-logging.md to L117-…
tanvi-jagtap Apr 29, 2024
3eaca82
Update L117-cpp-replacing-gpr-logging-with-abseil-logging.md
tanvi-jagtap Apr 29, 2024
5280e29
Update L117-cpp-replacing-gpr-logging-with-abseil-logging.md
tanvi-jagtap Apr 29, 2024
54444c6
Update L117-cpp-replacing-gpr-logging-with-abseil-logging.md
tanvi-jagtap Apr 29, 2024
b188df3
Update L117-cpp-replacing-gpr-logging-with-abseil-logging.md
tanvi-jagtap Apr 29, 2024
517c373
Update L117-cpp-replacing-gpr-logging-with-abseil-logging.md
tanvi-jagtap Apr 29, 2024
e2aba84
Fixed half the review comments
tanvi-jagtap May 6, 2024
ffa0b8d
Rename L117-cpp-replacing-gpr-logging-with-abseil-logging.md to L117-…
tanvi-jagtap May 6, 2024
9a3e553
Fixed 1 review comment
tanvi-jagtap May 6, 2024
330f69d
Edit rationale section
tanvi-jagtap May 7, 2024
c8a4e8a
Edit rationale section
tanvi-jagtap May 7, 2024
4a397af
Fixing typo
tanvi-jagtap May 11, 2024
607f1dc
Update L117-core-replace-gpr-logging-with-abseil-logging.md
tanvi-jagtap May 13, 2024
8027216
Update L117-core-replace-gpr-logging-with-abseil-logging.md
tanvi-jagtap May 13, 2024
bb0db9f
Update L117-core-replace-gpr-logging-with-abseil-logging.md
tanvi-jagtap May 16, 2024
5bf0223
Update L117-core-replace-gpr-logging-with-abseil-logging.md
tanvi-jagtap May 16, 2024
4198fc1
Update L117-core-replace-gpr-logging-with-abseil-logging.md
tanvi-jagtap May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
94 changes: 94 additions & 0 deletions L115-replacing-gpr-logging-with-abseil-logging.md
@@ -0,0 +1,94 @@
L116: Replacing gpr logging with Abseil logging
tanvi-jagtap marked this conversation as resolved.
Show resolved Hide resolved
----

* Author(s): tjagtap@google.com
* Approver: roth@google.com , ctiller@google.com
* Status: In Review
* Implemented in: gRPC C++
* Last updated: April 18, 2024.
* Discussion at: (filled after thread exists)

## Abstract

Replacing gpr logging and asserts with Abseil logging and asserts

## Background & Rationale

gRPC is currently maintaining its own version of the logging and assert APIs. The Abseil library released their logs and asserts too. We want to leverage the Abseil library and avoid maintaining our own logging code. Also, the current implementation of gpr_log uses format strings which are not type safe and have exploit potential. Moving to absl logging will eliminate this security risk.

## Related Proposals:

None.

## Proposal

We are proposing to remove all instances of gpr logging and asserts and replace them with their absl equivalents.

## Implementation

### References
* [gpr logging header](https://github.com/grpc/grpc/blame/83a17ff4684dc1fb3493a151ac0b655b1c55e766/include/grpc/support/log.h)
* [absl logging header](https://github.com/abseil/abseil-cpp/blob/master/absl/log/log.h)
* [absl assert header](https://github.com/abseil/abseil-cpp/blob/master/absl/log/check.h)

### Functions that will be removed, and their replacements
* `gpr_log`
* `gpr_log(GPR_DEBUG,...)` with `VLOG(2) << ...`
* `gpr_log(GPR_INFO,...)` with `LOG(INFO) < ...`
* `gpr_log(GPR_ERROR,...)` with `LOG(ERROR) < ...`
* `gpr_log_message`
* `gpr_log_message(GPR_DEBUG,...)` with `VLOG(2) << ...`
* `gpr_log_message(GPR_INFO,...)` with `LOG(INFO) < ...`
* `gpr_log_message(GPR_ERROR,...)` with `LOG(ERROR) < ...`
* Asserts
* `GPR_ASSERT(...)` with `CHECK(...)`
* `GPR_DEBUG_ASSERT(...)` with `DCHECK(...)`
* `gpr_assertion_failed` with `CHECK(...)`
* `gpr_set_log_function` - This function will be removed. Teams can consider usage of [LogSink](https://github.com/abseil/abseil-cpp/blob/fa57bfc573453d57a38552eedcce894b0e2d9f5e/absl/log/log_sink.h) and [AddLogSink](https://github.com/abseil/abseil-cpp/blob/fa57bfc573453d57a38552eedcce894b0e2d9f5e/absl/log/log_sink_registry.h).

### Functions that will be removed
* `gpr_log_severity_string` - This wont be needed anymore.
* `gpr_should_log` - This wont be needed anymore.

### Will work similar to before
* `gpr_set_log_verbosity` and GRPC_VERBOSITY will work as follows

```
void SomeInitFunctionCalledByGrpcInit() {
optional<string> verbosity = GetEnv("GRPC_VERBOSITY");
if (verbosity.has_value()) {
if (verbosity == "GPR_INFO" || verbosity == "INFO") {
SetMinLogLevel(INFO);
}
else if (verbosity == "GPR_ERROR" || verbosity == "ERROR") {
SetMinLogLevel(ERROR);
}
else if (verbosity == "WARNING") {
SetMinLogLevel(WARNING);
}
else if (verbosity == "GPR_DEBUG") {
SetGlobalVLogLevel(2);
SetMinLogLevel(INFO);
}
else {
LOG(ERROR) << "Unknown log verbosity: " << verbosity;
}
}
}

void gpr_set_log_verbosity(gpr_log_severity verbosity) {
if (verbosity == GPR_INFO) {
SetMinLogLevel(INFO);
}
else if (verbosity == GPR_ERROR) {
SetMinLogLevel(ERROR);
}
else if (verbosity == GPR_DEBUG) {
SetGlobalVLogLevel(2);
SetMinLogLevel(INFO);
}
else {
LOG(ERROR) << "Unknown log verbosity: " << verbosity;
}
}
```