blob: ef06a4822b703f4c1c6d1a22f29a95f1c13b75d6 [file] [log] [blame]
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -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
amit.ghosh258d14c2020-10-02 15:13:38 +020021import "google.golang.org/grpc/internal/grpclog"
22
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070023// Logger mimics golang's standard Logger as an interface.
24//
25// Deprecated: use LoggerV2.
26type Logger interface {
27 Fatal(args ...interface{})
28 Fatalf(format string, args ...interface{})
29 Fatalln(args ...interface{})
30 Print(args ...interface{})
31 Printf(format string, args ...interface{})
32 Println(args ...interface{})
33}
34
35// SetLogger sets the logger that is used in grpc. Call only from
36// init() functions.
37//
38// Deprecated: use SetLoggerV2.
39func SetLogger(l Logger) {
amit.ghosh258d14c2020-10-02 15:13:38 +020040 grpclog.Logger = &loggerWrapper{Logger: l}
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070041}
42
43// loggerWrapper wraps Logger into a LoggerV2.
44type loggerWrapper struct {
45 Logger
46}
47
48func (g *loggerWrapper) Info(args ...interface{}) {
49 g.Logger.Print(args...)
50}
51
52func (g *loggerWrapper) Infoln(args ...interface{}) {
53 g.Logger.Println(args...)
54}
55
56func (g *loggerWrapper) Infof(format string, args ...interface{}) {
57 g.Logger.Printf(format, args...)
58}
59
60func (g *loggerWrapper) Warning(args ...interface{}) {
61 g.Logger.Print(args...)
62}
63
64func (g *loggerWrapper) Warningln(args ...interface{}) {
65 g.Logger.Println(args...)
66}
67
68func (g *loggerWrapper) Warningf(format string, args ...interface{}) {
69 g.Logger.Printf(format, args...)
70}
71
72func (g *loggerWrapper) Error(args ...interface{}) {
73 g.Logger.Print(args...)
74}
75
76func (g *loggerWrapper) Errorln(args ...interface{}) {
77 g.Logger.Println(args...)
78}
79
80func (g *loggerWrapper) Errorf(format string, args ...interface{}) {
81 g.Logger.Printf(format, args...)
82}
83
84func (g *loggerWrapper) V(l int) bool {
85 // Returns true for all verbose level.
86 return true
87}