log-wrapper.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package backend
  2. import (
  3. "log"
  4. glog "github.com/grafana/grafana/pkg/log"
  5. hclog "github.com/hashicorp/go-hclog"
  6. )
  7. type LogWrapper struct {
  8. Logger glog.Logger
  9. }
  10. func (lw LogWrapper) Trace(msg string, args ...interface{}) {
  11. glog.Debug2(msg, args...)
  12. }
  13. func (lw LogWrapper) Debug(msg string, args ...interface{}) {
  14. glog.Debug2(msg, args...)
  15. }
  16. func (lw LogWrapper) Info(msg string, args ...interface{}) {
  17. glog.Info2(msg, args...)
  18. }
  19. func (lw LogWrapper) Warn(msg string, args ...interface{}) {
  20. glog.Warn2(msg, args...)
  21. }
  22. func (lw LogWrapper) Error(msg string, args ...interface{}) {
  23. glog.Error2(msg, args...)
  24. }
  25. func (lw LogWrapper) IsTrace() bool { return true }
  26. func (lw LogWrapper) IsDebug() bool { return true }
  27. func (lw LogWrapper) IsInfo() bool { return true }
  28. func (lw LogWrapper) IsWarn() bool { return true }
  29. func (lw LogWrapper) IsError() bool { return true }
  30. func (lw LogWrapper) With(args ...interface{}) hclog.Logger {
  31. return LogWrapper{Logger: glog.New("logger", args)}
  32. }
  33. func (lw LogWrapper) Named(name string) hclog.Logger {
  34. return LogWrapper{Logger: glog.New(name)}
  35. }
  36. func (lw LogWrapper) ResetNamed(name string) hclog.Logger {
  37. return LogWrapper{Logger: glog.New(name)}
  38. }
  39. func (lw LogWrapper) StandardLogger(ops *hclog.StandardLoggerOptions) *log.Logger {
  40. return nil
  41. }