Plugins: Use a Grafana specific SDK logger implementation for core plugins (#51229)

Upgrade grafana-aws-sdk to v0.10.6
This commit is contained in:
Marcus Efraimsson
2022-06-23 14:34:25 +02:00
committed by GitHub
parent 78ee9ffa37
commit a8eb29f1d7
3 changed files with 43 additions and 11 deletions

View File

@ -4,6 +4,8 @@ import (
"context"
"github.com/grafana/grafana-plugin-sdk-go/backend"
sdklog "github.com/grafana/grafana-plugin-sdk-go/backend/log"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor"
@ -41,6 +43,12 @@ const (
Grafana = "grafana"
)
func init() {
// Non-optimal global solution to replace plugin SDK default loggers for core plugins.
sdklog.DefaultLogger = &logWrapper{logger: log.New("plugin.coreplugin")}
backend.Logger = sdklog.DefaultLogger
}
type Registry struct {
store map[string]backendplugin.PluginFactoryFunc
}
@ -110,3 +118,27 @@ func asBackendPlugin(svc interface{}) backendplugin.PluginFactoryFunc {
return nil
}
type logWrapper struct {
logger log.Logger
}
func (l *logWrapper) Debug(msg string, args ...interface{}) {
l.logger.Debug(msg, args...)
}
func (l *logWrapper) Info(msg string, args ...interface{}) {
l.logger.Info(msg, args...)
}
func (l *logWrapper) Warn(msg string, args ...interface{}) {
l.logger.Warn(msg, args...)
}
func (l *logWrapper) Error(msg string, args ...interface{}) {
l.logger.Error(msg, args...)
}
func (l *logWrapper) Level() sdklog.Level {
return sdklog.NoLevel
}