blob: 874ea6d98a60356664f7008ff32ae8ed02f12e6e [file] [log] [blame]
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -07001/*
2 *
3 * Copyright 2017 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19// Package grpclog defines logging for grpc.
20//
21// All logs in transport and grpclb packages only go to verbose level 2.
22// All logs in other packages in grpc are logged in spite of the verbosity level.
23//
24// In the default logger,
25// severity level can be set by environment variable GRPC_GO_LOG_SEVERITY_LEVEL,
26// verbosity level can be set by GRPC_GO_LOG_VERBOSITY_LEVEL.
27package grpclog // import "google.golang.org/grpc/grpclog"
28
David K. Bainbridgec415efe2021-08-19 13:05:21 +000029import "os"
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070030
David K. Bainbridgec415efe2021-08-19 13:05:21 +000031var logger = newLoggerV2()
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070032
33// V reports whether verbosity level l is at least the requested verbose level.
34func V(l int) bool {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000035 return logger.V(l)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070036}
37
38// Info logs to the INFO log.
39func Info(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000040 logger.Info(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070041}
42
43// Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf.
44func Infof(format string, args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000045 logger.Infof(format, args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070046}
47
48// Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println.
49func Infoln(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000050 logger.Infoln(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070051}
52
53// Warning logs to the WARNING log.
54func Warning(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000055 logger.Warning(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070056}
57
58// Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf.
59func Warningf(format string, args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000060 logger.Warningf(format, args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070061}
62
63// Warningln logs to the WARNING log. Arguments are handled in the manner of fmt.Println.
64func Warningln(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000065 logger.Warningln(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070066}
67
68// Error logs to the ERROR log.
69func Error(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000070 logger.Error(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070071}
72
73// Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf.
74func Errorf(format string, args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000075 logger.Errorf(format, args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070076}
77
78// Errorln logs to the ERROR log. Arguments are handled in the manner of fmt.Println.
79func Errorln(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000080 logger.Errorln(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070081}
82
83// Fatal logs to the FATAL log. Arguments are handled in the manner of fmt.Print.
84// It calls os.Exit() with exit code 1.
85func Fatal(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000086 logger.Fatal(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070087 // Make sure fatal logs will exit.
88 os.Exit(1)
89}
90
91// Fatalf logs to the FATAL log. Arguments are handled in the manner of fmt.Printf.
Arjun E K57a7fcb2020-01-30 06:44:45 +000092// It calls os.Exit() with exit code 1.
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070093func Fatalf(format string, args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +000094 logger.Fatalf(format, args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070095 // Make sure fatal logs will exit.
96 os.Exit(1)
97}
98
99// Fatalln logs to the FATAL log. Arguments are handled in the manner of fmt.Println.
100// It calle os.Exit()) with exit code 1.
101func Fatalln(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000102 logger.Fatalln(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700103 // Make sure fatal logs will exit.
104 os.Exit(1)
105}
106
107// Print prints to the logger. Arguments are handled in the manner of fmt.Print.
108//
109// Deprecated: use Info.
110func Print(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000111 logger.Info(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700112}
113
114// Printf prints to the logger. Arguments are handled in the manner of fmt.Printf.
115//
116// Deprecated: use Infof.
117func Printf(format string, args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000118 logger.Infof(format, args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700119}
120
121// Println prints to the logger. Arguments are handled in the manner of fmt.Println.
122//
123// Deprecated: use Infoln.
124func Println(args ...interface{}) {
David K. Bainbridgec415efe2021-08-19 13:05:21 +0000125 logger.Infoln(args...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700126}