• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 The gRPC Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.grpc;
18 
19 import javax.annotation.concurrent.ThreadSafe;
20 
21 /**
22  * A Channel-specific logger provided by GRPC library to {@link LoadBalancer} implementations.
23  * Information logged here goes to <strong>Channelz</strong>, and to the Java logger of this class
24  * as well.
25  */
26 @ExperimentalApi("https://github.com/grpc/grpc-java/issues/5029")
27 @ThreadSafe
28 public abstract class ChannelLogger {
29   /**
30    * Log levels.  See the table below for the mapping from the ChannelLogger levels to Channelz
31    * severity level (see {@code ChannelTraceEvent} from <a
32    * href="https://github.com/grpc/grpc-java/blob/master/services/src/main/proto/grpc/channelz/v1/channelz.proto">channelz.proto</a>)
33    * and Java logger levels.  Note that {@code DEBUG} level is not recorded on Channelz.
34    * <pre>
35    * +---------------------+-------------------+-------------------+
36    * | ChannelLogger Level | Channelz Severity | Java Logger Level |
37    * +---------------------+-------------------+-------------------+
38    * | DEBUG               | N/A               | FINEST            |
39    * | INFO                | CT_INFO           | FINER             |
40    * | WARNING             | CT_WARNING        | FINE             |
41    * | ERROR               | CT_ERROR          | FINE              |
42    * +---------------------+-------------------+-------------------+
43    * </pre>
44    */
45   public enum ChannelLogLevel {
46     DEBUG,
47     INFO,
48     WARNING,
49     ERROR
50   }
51 
52   /**
53    * Logs a message.
54    */
log(ChannelLogLevel level, String message)55   public abstract void log(ChannelLogLevel level, String message);
56 
57   /**
58    * Logs a message, using a message format and a list of arguments used to generate the log
59    * message with {@link java.text.MessageFormat}.
60    */
log(ChannelLogLevel level, String messageFormat, Object... args)61   public abstract void log(ChannelLogLevel level, String messageFormat, Object... args);
62 }
63