[v9.0.x] Plugins: Use a Grafana specific SDK logger implementation for core plugins (#51229) (#51325)

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

Upgrade grafana-aws-sdk to v0.10.6

(cherry picked from commit a8eb29f1d7)

* fix go.mod go.sum
This commit is contained in:
Marcus Efraimsson
2022-06-27 12:22:28 +02:00
committed by GitHub
parent 813b3873f5
commit e037f7ace7
2 changed files with 34 additions and 9 deletions
@@ -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
}