khenaidoo | c6c7bda | 2020-06-17 17:20:18 -0400 | [diff] [blame] | 1 | // 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 | |
| 15 | package jaeger |
| 16 | |
| 17 | import "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). |
| 25 | type 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 |
| 34 | var StdLogger = &stdLogger{} |
| 35 | |
| 36 | type stdLogger struct{} |
| 37 | |
| 38 | func (l *stdLogger) Error(msg string) { |
| 39 | log.Printf("ERROR: %s", msg) |
| 40 | } |
| 41 | |
| 42 | // Infof logs a message at info priority |
| 43 | func (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 |
| 48 | var NullLogger = &nullLogger{} |
| 49 | |
| 50 | type nullLogger struct{} |
| 51 | |
| 52 | func (l *nullLogger) Error(msg string) {} |
| 53 | func (l *nullLogger) Infof(msg string, args ...interface{}) {} |