logger.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. package jaeger
  15. import "log"
  16. // NB This will be deprecated in 3.0.0, please use jaeger-client-go/log/logger instead.
  17. // Logger provides an abstract interface for logging from Reporters.
  18. // Applications can provide their own implementation of this interface to adapt
  19. // reporters logging to whatever logging library they prefer (stdlib log,
  20. // logrus, go-logging, etc).
  21. type Logger interface {
  22. // Error logs a message at error priority
  23. Error(msg string)
  24. // Infof logs a message at info priority
  25. Infof(msg string, args ...interface{})
  26. }
  27. // StdLogger is implementation of the Logger interface that delegates to default `log` package
  28. var StdLogger = &stdLogger{}
  29. type stdLogger struct{}
  30. func (l *stdLogger) Error(msg string) {
  31. log.Printf("ERROR: %s", msg)
  32. }
  33. // Infof logs a message at info priority
  34. func (l *stdLogger) Infof(msg string, args ...interface{}) {
  35. log.Printf(msg, args...)
  36. }
  37. // NullLogger is implementation of the Logger interface that delegates to default `log` package
  38. var NullLogger = &nullLogger{}
  39. type nullLogger struct{}
  40. func (l *nullLogger) Error(msg string) {}
  41. func (l *nullLogger) Infof(msg string, args ...interface{}) {}