Skip to content

Commit

Permalink
Update ChannelLogger to Java logger level mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouyihaiDing committed Sep 17, 2021
1 parent 38a554c commit 188ecd9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions api/src/main/java/io/grpc/ChannelLogger.java
Expand Up @@ -36,8 +36,8 @@ public abstract class ChannelLogger {
* | ChannelLogger Level | Channelz Severity | Java Logger Level |
* +---------------------+-------------------+-------------------+
* | DEBUG | N/A | FINEST |
* | INFO | CT_INFO | FINEST |
* | WARNING | CT_WARNING | FINER |
* | INFO | CT_INFO | FINER |
* | WARNING | CT_WARNING | FINE |
* | ERROR | CT_ERROR | FINE |
* +---------------------+-------------------+-------------------+
* </pre>
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/io/grpc/internal/ChannelLoggerImpl.java
Expand Up @@ -97,8 +97,9 @@ private static Severity toTracerSeverity(ChannelLogLevel level) {
private static Level toJavaLogLevel(ChannelLogLevel level) {
switch (level) {
case ERROR:
return Level.FINE;
case WARNING:
return Level.FINE;
case INFO:
return Level.FINER;
default:
return Level.FINEST;
Expand Down
Expand Up @@ -100,7 +100,7 @@ public void logging() {
.setTimestampNanos(200)
.build();
assertThat(stats.channelTrace.events).containsExactly(event);
assertThat(logs).contains("FINER: " + logPrefix + "Warning message");
assertThat(logs).contains("FINE: " + logPrefix + "Warning message");

clock.forwardNanos(100);
logger.log(ChannelLogLevel.INFO, "Info message");
Expand All @@ -112,7 +112,7 @@ public void logging() {
.setTimestampNanos(300)
.build();
assertThat(stats.channelTrace.events).containsExactly(event);
assertThat(logs).contains("FINEST: " + logPrefix + "Info message");
assertThat(logs).contains("FINER: " + logPrefix + "Info message");

clock.forwardNanos(100);
logger.log(ChannelLogLevel.DEBUG, "Debug message");
Expand Down Expand Up @@ -154,7 +154,7 @@ public void formatLogging() {
.setTimestampNanos(200)
.build();
assertThat(stats.channelTrace.events).containsExactly(event);
assertThat(logs).contains("FINER: " + logPrefix + "Warning message foo, bar");
assertThat(logs).contains("FINE: " + logPrefix + "Warning message foo, bar");

clock.forwardNanos(100);
logger.log(ChannelLogLevel.INFO, "Info message {0}", "bar");
Expand All @@ -166,7 +166,7 @@ public void formatLogging() {
.setTimestampNanos(300)
.build();
assertThat(stats.channelTrace.events).containsExactly(event);
assertThat(logs).contains("FINEST: " + logPrefix + "Info message bar");
assertThat(logs).contains("FINER: " + logPrefix + "Info message bar");

clock.forwardNanos(100);
logger.log(ChannelLogLevel.DEBUG, "Debug message {0}", "foo");
Expand Down

0 comments on commit 188ecd9

Please sign in to comment.