hclog-wrapper.go 1.29 KB
Newer Older
1
package plugins
2 3 4 5 6 7 8 9

import (
	"log"

	glog "github.com/grafana/grafana/pkg/log"
	hclog "github.com/hashicorp/go-hclog"
)

10 11
type LogWrapper struct {
	Logger glog.Logger
12 13
}

14
func (lw LogWrapper) Trace(msg string, args ...interface{}) {
15
	lw.Logger.Debug(msg, args...)
16 17
}
func (lw LogWrapper) Debug(msg string, args ...interface{}) {
18
	lw.Logger.Debug(msg, args...)
19 20
}
func (lw LogWrapper) Info(msg string, args ...interface{}) {
21
	lw.Logger.Info(msg, args...)
22 23
}
func (lw LogWrapper) Warn(msg string, args ...interface{}) {
24
	lw.Logger.Warn(msg, args...)
25 26
}
func (lw LogWrapper) Error(msg string, args ...interface{}) {
27
	lw.Logger.Error(msg, args...)
28
}
29

30 31 32 33 34
func (lw LogWrapper) IsTrace() bool { return true }
func (lw LogWrapper) IsDebug() bool { return true }
func (lw LogWrapper) IsInfo() bool  { return true }
func (lw LogWrapper) IsWarn() bool  { return true }
func (lw LogWrapper) IsError() bool { return true }
35

36
func (lw LogWrapper) With(args ...interface{}) hclog.Logger {
37
	return LogWrapper{Logger: lw.Logger.New(args...)}
38
}
39
func (lw LogWrapper) Named(name string) hclog.Logger {
40
	return LogWrapper{Logger: lw.Logger.New()}
41
}
42

43
func (lw LogWrapper) ResetNamed(name string) hclog.Logger {
44
	return LogWrapper{Logger: lw.Logger.New()}
45 46
}

47
func (lw LogWrapper) StandardLogger(ops *hclog.StandardLoggerOptions) *log.Logger {
48 49
	return nil
}