blob: d4f0b501923d51b42d27f55b6ec84e40c7185a65 [file] [log] [blame]
Takahiro Suzukid7bf8202020-12-17 20:21:59 +09001// Copyright (c) 2017 Uber Technologies, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package jaeger
16
17import "log"
18
19// NB This will be deprecated in 3.0.0, please use jaeger-client-go/log/logger instead.
20
21// Logger provides an abstract interface for logging from Reporters.
22// Applications can provide their own implementation of this interface to adapt
23// reporters logging to whatever logging library they prefer (stdlib log,
24// logrus, go-logging, etc).
25type Logger interface {
26 // Error logs a message at error priority
27 Error(msg string)
28
29 // Infof logs a message at info priority
30 Infof(msg string, args ...interface{})
31}
32
33// StdLogger is implementation of the Logger interface that delegates to default `log` package
34var StdLogger = &stdLogger{}
35
36type stdLogger struct{}
37
38func (l *stdLogger) Error(msg string) {
39 log.Printf("ERROR: %s", msg)
40}
41
42// Infof logs a message at info priority
43func (l *stdLogger) Infof(msg string, args ...interface{}) {
44 log.Printf(msg, args...)
45}
46
47// NullLogger is implementation of the Logger interface that delegates to default `log` package
48var NullLogger = &nullLogger{}
49
50type nullLogger struct{}
51
52func (l *nullLogger) Error(msg string) {}
53func (l *nullLogger) Infof(msg string, args ...interface{}) {}