Plugins: Introduce plugin package specific logger (#62204)

* refactor

* implement with infra log for now

* undo moving

* update package name

* update name

* fix tests

* update pretty signature

* update naming

* simplify

* fix typo

* delete comment

* fix import

* retrigger
This commit is contained in:
Will Browne
2023-02-28 16:10:27 +01:00
committed by GitHub
parent ab8de1a0e3
commit ec82719372
38 changed files with 259 additions and 140 deletions
+44
View File
@@ -0,0 +1,44 @@
package log
import (
"github.com/grafana/grafana/pkg/infra/log"
)
func New(name string) Logger {
return &grafanaInfraLogWrapper{
l: log.New(name),
}
}
type grafanaInfraLogWrapper struct {
l *log.ConcreteLogger
}
func (d *grafanaInfraLogWrapper) New(ctx ...interface{}) Logger {
if len(ctx) == 0 {
return &grafanaInfraLogWrapper{
l: d.l.New(),
}
}
ctx = append([]interface{}{"logger"}, ctx...)
return &grafanaInfraLogWrapper{
l: d.l.New(ctx...),
}
}
func (d *grafanaInfraLogWrapper) Debug(msg string, ctx ...interface{}) {
d.l.Debug(msg, ctx...)
}
func (d *grafanaInfraLogWrapper) Info(msg string, ctx ...interface{}) {
d.l.Info(msg, ctx...)
}
func (d *grafanaInfraLogWrapper) Warn(msg string, ctx ...interface{}) {
d.l.Warn(msg, ctx...)
}
func (d *grafanaInfraLogWrapper) Error(msg string, ctx ...interface{}) {
d.l.Error(msg, ctx...)
}