blob: 097494f710f5b1ac4636436a1d8754ca06ac56e4 [file] [log] [blame]
Scott Bakereee8dd82019-09-24 12:52:34 -07001/*
2 *
3 * Copyright 2015 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
19package grpclog
20
21// Logger mimics golang's standard Logger as an interface.
22//
23// Deprecated: use LoggerV2.
24type Logger interface {
25 Fatal(args ...interface{})
26 Fatalf(format string, args ...interface{})
27 Fatalln(args ...interface{})
28 Print(args ...interface{})
29 Printf(format string, args ...interface{})
30 Println(args ...interface{})
31}
32
33// SetLogger sets the logger that is used in grpc. Call only from
34// init() functions.
35//
36// Deprecated: use SetLoggerV2.
37func SetLogger(l Logger) {
38 logger = &loggerWrapper{Logger: l}
39}
40
41// loggerWrapper wraps Logger into a LoggerV2.
42type loggerWrapper struct {
43 Logger
44}
45
46func (g *loggerWrapper) Info(args ...interface{}) {
47 g.Logger.Print(args...)
48}
49
50func (g *loggerWrapper) Infoln(args ...interface{}) {
51 g.Logger.Println(args...)
52}
53
54func (g *loggerWrapper) Infof(format string, args ...interface{}) {
55 g.Logger.Printf(format, args...)
56}
57
58func (g *loggerWrapper) Warning(args ...interface{}) {
59 g.Logger.Print(args...)
60}
61
62func (g *loggerWrapper) Warningln(args ...interface{}) {
63 g.Logger.Println(args...)
64}
65
66func (g *loggerWrapper) Warningf(format string, args ...interface{}) {
67 g.Logger.Printf(format, args...)
68}
69
70func (g *loggerWrapper) Error(args ...interface{}) {
71 g.Logger.Print(args...)
72}
73
74func (g *loggerWrapper) Errorln(args ...interface{}) {
75 g.Logger.Println(args...)
76}
77
78func (g *loggerWrapper) Errorf(format string, args ...interface{}) {
79 g.Logger.Printf(format, args...)
80}
81
82func (g *loggerWrapper) V(l int) bool {
83 // Returns true for all verbose level.
84 return true
85}