cubefs
132 строки · 3.8 Кб
1/*
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
29import (
30"os"
31
32"google.golang.org/grpc/internal/grpclog"
33)
34
35func init() {
36SetLoggerV2(newLoggerV2())
37}
38
39// V reports whether verbosity level l is at least the requested verbose level.
40func V(l int) bool {
41return grpclog.Logger.V(l)
42}
43
44// Info logs to the INFO log.
45func Info(args ...interface{}) {
46grpclog.Logger.Info(args...)
47}
48
49// Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf.
50func Infof(format string, args ...interface{}) {
51grpclog.Logger.Infof(format, args...)
52}
53
54// Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println.
55func Infoln(args ...interface{}) {
56grpclog.Logger.Infoln(args...)
57}
58
59// Warning logs to the WARNING log.
60func Warning(args ...interface{}) {
61grpclog.Logger.Warning(args...)
62}
63
64// Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf.
65func Warningf(format string, args ...interface{}) {
66grpclog.Logger.Warningf(format, args...)
67}
68
69// Warningln logs to the WARNING log. Arguments are handled in the manner of fmt.Println.
70func Warningln(args ...interface{}) {
71grpclog.Logger.Warningln(args...)
72}
73
74// Error logs to the ERROR log.
75func Error(args ...interface{}) {
76grpclog.Logger.Error(args...)
77}
78
79// Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf.
80func Errorf(format string, args ...interface{}) {
81grpclog.Logger.Errorf(format, args...)
82}
83
84// Errorln logs to the ERROR log. Arguments are handled in the manner of fmt.Println.
85func Errorln(args ...interface{}) {
86grpclog.Logger.Errorln(args...)
87}
88
89// Fatal logs to the FATAL log. Arguments are handled in the manner of fmt.Print.
90// It calls os.Exit() with exit code 1.
91func Fatal(args ...interface{}) {
92grpclog.Logger.Fatal(args...)
93// Make sure fatal logs will exit.
94os.Exit(1)
95}
96
97// Fatalf logs to the FATAL log. Arguments are handled in the manner of fmt.Printf.
98// It calls os.Exit() with exit code 1.
99func Fatalf(format string, args ...interface{}) {
100grpclog.Logger.Fatalf(format, args...)
101// Make sure fatal logs will exit.
102os.Exit(1)
103}
104
105// Fatalln logs to the FATAL log. Arguments are handled in the manner of fmt.Println.
106// It calle os.Exit()) with exit code 1.
107func Fatalln(args ...interface{}) {
108grpclog.Logger.Fatalln(args...)
109// Make sure fatal logs will exit.
110os.Exit(1)
111}
112
113// Print prints to the logger. Arguments are handled in the manner of fmt.Print.
114//
115// Deprecated: use Info.
116func Print(args ...interface{}) {
117grpclog.Logger.Info(args...)
118}
119
120// Printf prints to the logger. Arguments are handled in the manner of fmt.Printf.
121//
122// Deprecated: use Infof.
123func Printf(format string, args ...interface{}) {
124grpclog.Logger.Infof(format, args...)
125}
126
127// Println prints to the logger. Arguments are handled in the manner of fmt.Println.
128//
129// Deprecated: use Infoln.
130func Println(args ...interface{}) {
131grpclog.Logger.Infoln(args...)
132}
133