2023-02-28 09:10:27 -06:00
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
2023-10-11 05:42:32 -05:00
|
|
|
"context"
|
|
|
|
|
2023-02-28 09:10:27 -06:00
|
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func New(name string) Logger {
|
|
|
|
return &grafanaInfraLogWrapper{
|
|
|
|
l: log.New(name),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type grafanaInfraLogWrapper struct {
|
|
|
|
l *log.ConcreteLogger
|
|
|
|
}
|
|
|
|
|
2023-08-30 10:46:47 -05:00
|
|
|
func (d *grafanaInfraLogWrapper) New(ctx ...any) Logger {
|
2023-02-28 09:10:27 -06:00
|
|
|
if len(ctx) == 0 {
|
|
|
|
return &grafanaInfraLogWrapper{
|
|
|
|
l: d.l.New(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &grafanaInfraLogWrapper{
|
|
|
|
l: d.l.New(ctx...),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-30 10:46:47 -05:00
|
|
|
func (d *grafanaInfraLogWrapper) Debug(msg string, ctx ...any) {
|
2023-02-28 09:10:27 -06:00
|
|
|
d.l.Debug(msg, ctx...)
|
|
|
|
}
|
|
|
|
|
2023-08-30 10:46:47 -05:00
|
|
|
func (d *grafanaInfraLogWrapper) Info(msg string, ctx ...any) {
|
2023-02-28 09:10:27 -06:00
|
|
|
d.l.Info(msg, ctx...)
|
|
|
|
}
|
|
|
|
|
2023-08-30 10:46:47 -05:00
|
|
|
func (d *grafanaInfraLogWrapper) Warn(msg string, ctx ...any) {
|
2023-02-28 09:10:27 -06:00
|
|
|
d.l.Warn(msg, ctx...)
|
|
|
|
}
|
|
|
|
|
2023-08-30 10:46:47 -05:00
|
|
|
func (d *grafanaInfraLogWrapper) Error(msg string, ctx ...any) {
|
2023-02-28 09:10:27 -06:00
|
|
|
d.l.Error(msg, ctx...)
|
|
|
|
}
|
2023-10-11 05:42:32 -05:00
|
|
|
|
|
|
|
func (d *grafanaInfraLogWrapper) FromContext(ctx context.Context) Logger {
|
|
|
|
concreteInfraLogger, ok := d.l.FromContext(ctx).(*log.ConcreteLogger)
|
|
|
|
if !ok {
|
|
|
|
return d.New()
|
|
|
|
}
|
|
|
|
return &grafanaInfraLogWrapper{
|
|
|
|
l: concreteInfraLogger,
|
|
|
|
}
|
|
|
|
}
|