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 15:10:27 +00:00 committed by GitHub
parent ab8de1a0e3
commit ec82719372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 259 additions and 140 deletions

View File

@ -2,7 +2,7 @@
package backendplugin
import (
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/log"
)
// PluginFactoryFunc is a function type for creating a Plugin.

View File

@ -4,8 +4,9 @@ import (
"context"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/log"
)
// corePlugin represents a plugin that's part of Grafana core.

View File

@ -5,9 +5,9 @@ import (
"testing"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/backendplugin/coreplugin"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/stretchr/testify/require"
)

View File

@ -5,9 +5,10 @@ import (
"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/plugins/log"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor"
"github.com/grafana/grafana/pkg/tsdb/cloudmonitoring"
"github.com/grafana/grafana/pkg/tsdb/cloudwatch"

View File

@ -4,14 +4,15 @@ import (
"os/exec"
"github.com/grafana/grafana-plugin-sdk-go/backend/grpcplugin"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/backendplugin/pluginextensionv2"
"github.com/grafana/grafana/pkg/plugins/backendplugin/secretsmanagerplugin"
grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
goplugin "github.com/hashicorp/go-plugin"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/backendplugin/pluginextensionv2"
"github.com/grafana/grafana/pkg/plugins/backendplugin/secretsmanagerplugin"
"github.com/grafana/grafana/pkg/plugins/log"
)
// Handshake is the HandshakeConfig used to configure clients and servers.

View File

@ -9,13 +9,14 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/grpcplugin"
"github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/backendplugin/pluginextensionv2"
"github.com/grafana/grafana/pkg/plugins/backendplugin/secretsmanagerplugin"
"github.com/hashicorp/go-plugin"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/backendplugin/pluginextensionv2"
"github.com/grafana/grafana/pkg/plugins/backendplugin/secretsmanagerplugin"
"github.com/grafana/grafana/pkg/plugins/log"
)
type ClientV2 struct {

View File

@ -6,10 +6,11 @@ import (
"sync"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/hashicorp/go-plugin"
"github.com/grafana/grafana/pkg/infra/process"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/hashicorp/go-plugin"
"github.com/grafana/grafana/pkg/plugins/log"
)
type pluginClient interface {

View File

@ -5,12 +5,13 @@ import (
"io"
"log"
glog "github.com/grafana/grafana/pkg/infra/log"
"github.com/hashicorp/go-hclog"
plog "github.com/grafana/grafana/pkg/plugins/log"
)
type logWrapper struct {
Logger glog.Logger
Logger plog.Logger
name string
impliedArgs []interface{}

View File

@ -4,7 +4,8 @@ import (
"context"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/log"
)
// Plugin is the backend plugin interface.

View File

@ -12,6 +12,7 @@ import (
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
plog "github.com/grafana/grafana/pkg/plugins/log"
)
var (
@ -29,7 +30,7 @@ var (
}, []string{"plugin_id", "endpoint", "target"})
)
var logger log.Logger = log.New("plugin.instrumentation")
var logger = plog.New("plugin.instrumentation")
// instrumentPluginRequest instruments success rate and latency of `fn`
func instrumentPluginRequest(ctx context.Context, cfg Cfg, pluginCtx *backend.PluginContext, endpoint string, fn func() error) error {

View File

@ -3,13 +3,13 @@ package provider
import (
"context"
"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/plugins/backendplugin/coreplugin"
"github.com/grafana/grafana/pkg/plugins/backendplugin/grpcplugin"
"github.com/grafana/grafana/pkg/plugins/backendplugin/pluginextensionv2"
"github.com/grafana/grafana/pkg/plugins/backendplugin/secretsmanagerplugin"
"github.com/grafana/grafana/pkg/plugins/log"
)
// PluginBackendProvider is a function type for initializing a Plugin backend.

View File

@ -5,7 +5,7 @@ import (
"github.com/grafana/grafana-azure-sdk-go/azsettings"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/setting"
)

48
pkg/plugins/log/fake.go Normal file
View File

@ -0,0 +1,48 @@
package log
var _ Logger = (*TestLogger)(nil)
type TestLogger struct {
DebugLogs Logs
InfoLogs Logs
WarnLogs Logs
ErrorLogs Logs
}
func NewTestLogger() *TestLogger {
return &TestLogger{}
}
func (f *TestLogger) New(_ ...interface{}) Logger {
return NewTestLogger()
}
func (f *TestLogger) Info(msg string, ctx ...interface{}) {
f.InfoLogs.Calls++
f.InfoLogs.Message = msg
f.InfoLogs.Ctx = ctx
}
func (f *TestLogger) Warn(msg string, ctx ...interface{}) {
f.WarnLogs.Calls++
f.WarnLogs.Message = msg
f.WarnLogs.Ctx = ctx
}
func (f *TestLogger) Debug(msg string, ctx ...interface{}) {
f.DebugLogs.Calls++
f.DebugLogs.Message = msg
f.DebugLogs.Ctx = ctx
}
func (f *TestLogger) Error(msg string, ctx ...interface{}) {
f.ErrorLogs.Calls++
f.ErrorLogs.Message = msg
f.ErrorLogs.Ctx = ctx
}
type Logs struct {
Calls int
Message string
Ctx []interface{}
}

35
pkg/plugins/log/ifaces.go Normal file
View File

@ -0,0 +1,35 @@
package log
// Logger is the default logger
type Logger interface {
// New returns a new contextual Logger that has this logger's context plus the given context.
New(ctx ...interface{}) Logger
// Debug logs a message with debug level and key/value pairs, if any.
Debug(msg string, ctx ...interface{})
// Info logs a message with info level and key/value pairs, if any.
Info(msg string, ctx ...interface{})
// Warn logs a message with warning level and key/value pairs, if any.
Warn(msg string, ctx ...interface{})
// Error logs a message with error level and key/value pairs, if any.
Error(msg string, ctx ...interface{})
}
// PrettyLogger is used primarily to facilitate logging/user feedback for both
// the grafana-cli and the grafana backend when managing plugin installs
type PrettyLogger interface {
Successf(format string, args ...interface{})
Failuref(format string, args ...interface{})
Info(args ...interface{})
Infof(format string, args ...interface{})
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Warn(args ...interface{})
Warnf(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
}

View File

@ -0,0 +1,57 @@
package log
import (
"fmt"
)
var _ PrettyLogger = (*prettyLogger)(nil)
type prettyLogger struct {
log Logger
}
func NewPrettyLogger(name string) *prettyLogger {
return &prettyLogger{
log: New(name),
}
}
func (l *prettyLogger) Successf(format string, args ...interface{}) {
l.log.Info(fmt.Sprintf(format, args...))
}
func (l *prettyLogger) Failuref(format string, args ...interface{}) {
l.log.Error(fmt.Sprintf(format, args...))
}
func (l *prettyLogger) Info(args ...interface{}) {
l.log.Info(fmt.Sprint(args...))
}
func (l *prettyLogger) Infof(format string, args ...interface{}) {
l.log.Info(fmt.Sprintf(format, args...))
}
func (l *prettyLogger) Debug(args ...interface{}) {
l.log.Debug(fmt.Sprint(args...))
}
func (l *prettyLogger) Debugf(format string, args ...interface{}) {
l.log.Debug(fmt.Sprintf(format, args...))
}
func (l *prettyLogger) Warn(args ...interface{}) {
l.log.Warn(fmt.Sprint(args...))
}
func (l *prettyLogger) Warnf(format string, args ...interface{}) {
l.log.Warn(fmt.Sprintf(format, args...))
}
func (l *prettyLogger) Error(args ...interface{}) {
l.log.Error(fmt.Sprint(args...))
}
func (l *prettyLogger) Errorf(format string, args ...interface{}) {
l.log.Error(fmt.Sprintf(format, args...))
}

44
pkg/plugins/log/logger.go Normal file
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...)
}

View File

@ -1,17 +0,0 @@
package logger
// Logger is used primarily to facilitate logging/user feedback for both
// the grafana-cli and the grafana backend when managing plugin installs
type Logger interface {
Successf(format string, args ...interface{})
Failuref(format string, args ...interface{})
Info(args ...interface{})
Infof(format string, args ...interface{})
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Warn(args ...interface{})
Warnf(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
}

View File

@ -1,57 +0,0 @@
package logger
import (
"fmt"
"github.com/grafana/grafana/pkg/infra/log"
)
type InfraLogWrapper struct {
log log.Logger
}
func NewLogger(name string) *InfraLogWrapper {
return &InfraLogWrapper{
log: log.New(name),
}
}
func (l *InfraLogWrapper) Successf(format string, args ...interface{}) {
l.log.Info(fmt.Sprintf(format, args...))
}
func (l *InfraLogWrapper) Failuref(format string, args ...interface{}) {
l.log.Error(fmt.Sprintf(format, args...))
}
func (l *InfraLogWrapper) Info(args ...interface{}) {
l.log.Info(fmt.Sprint(args...))
}
func (l *InfraLogWrapper) Infof(format string, args ...interface{}) {
l.log.Info(fmt.Sprintf(format, args...))
}
func (l *InfraLogWrapper) Debug(args ...interface{}) {
l.log.Debug(fmt.Sprint(args...))
}
func (l *InfraLogWrapper) Debugf(format string, args ...interface{}) {
l.log.Debug(fmt.Sprintf(format, args...))
}
func (l *InfraLogWrapper) Warn(args ...interface{}) {
l.log.Warn(fmt.Sprint(args...))
}
func (l *InfraLogWrapper) Warnf(format string, args ...interface{}) {
l.log.Warn(fmt.Sprintf(format, args...))
}
func (l *InfraLogWrapper) Error(args ...interface{}) {
l.log.Error(fmt.Sprint(args...))
}
func (l *InfraLogWrapper) Errorf(format string, args ...interface{}) {
l.log.Error(fmt.Sprintf(format, args...))
}

View File

@ -8,9 +8,9 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
"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/plugins/log"
"github.com/grafana/grafana/pkg/plugins/repo"
"github.com/grafana/grafana/pkg/plugins/storage"
)

View File

@ -4,10 +4,9 @@ import (
"context"
"fmt"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/config"
"github.com/grafana/grafana/pkg/plugins/logger"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/plugins/manager/loader"
"github.com/grafana/grafana/pkg/plugins/manager/registry"
"github.com/grafana/grafana/pkg/plugins/repo"
@ -26,7 +25,7 @@ type PluginInstaller struct {
func ProvideInstaller(cfg *config.Cfg, pluginRegistry registry.Service, pluginLoader loader.Service,
pluginRepo repo.Service) *PluginInstaller {
return New(pluginRegistry, pluginLoader, pluginRepo, storage.FileSystem(logger.NewLogger("installer.fs"), cfg.PluginsPath))
return New(pluginRegistry, pluginLoader, pluginRepo, storage.FileSystem(log.NewPrettyLogger("installer.fs"), cfg.PluginsPath))
}
func New(pluginRegistry registry.Service, pluginLoader loader.Service, pluginRepo repo.Service,

View File

@ -6,12 +6,13 @@ import (
"fmt"
"testing"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
"github.com/grafana/grafana/pkg/plugins/repo"
"github.com/grafana/grafana/pkg/plugins/storage"
"github.com/stretchr/testify/require"
)
const testPluginID = "test-plugin"
@ -207,7 +208,7 @@ func createPlugin(t *testing.T, pluginID string, class plugins.Class, managed, b
Backend: backend,
},
}
p.SetLogger(log.NewNopLogger())
p.SetLogger(log.NewTestLogger())
p.RegisterClient(&fakes.FakePluginClient{
ID: pluginID,
Managed: managed,

View File

@ -7,7 +7,7 @@ import (
"path/filepath"
"github.com/grafana/grafana/pkg/infra/fs"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/util"
)

View File

@ -7,7 +7,7 @@ import (
"strings"
"testing"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/util"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -75,7 +75,7 @@ func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
})
finder := &Finder{
log: log.New(),
log: log.NewTestLogger(),
}
paths, err := finder.getAbsPluginJSONPaths("test")
@ -93,7 +93,7 @@ func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
})
finder := &Finder{
log: log.New(),
log: log.NewTestLogger(),
}
paths, err := finder.getAbsPluginJSONPaths("test")
@ -111,7 +111,7 @@ func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
})
finder := &Finder{
log: log.New(),
log: log.NewTestLogger(),
}
paths, err := finder.getAbsPluginJSONPaths("test")

View File

@ -9,9 +9,9 @@ import (
"github.com/grafana/grafana-aws-sdk/pkg/awsds"
"github.com/grafana/grafana-azure-sdk-go/azsettings"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/config"
"github.com/grafana/grafana/pkg/plugins/log"
)
type Initializer struct {

View File

@ -7,10 +7,10 @@ import (
"github.com/stretchr/testify/assert"
"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/plugins/config"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
)
@ -37,7 +37,7 @@ func TestInitializer_Initialize(t *testing.T) {
i := &Initializer{
cfg: &config.Cfg{},
log: log.NewNopLogger(),
log: log.NewTestLogger(),
backendProvider: &fakeBackendProvider{
plugin: p,
},
@ -67,7 +67,7 @@ func TestInitializer_Initialize(t *testing.T) {
i := &Initializer{
cfg: &config.Cfg{},
log: log.NewNopLogger(),
log: log.NewTestLogger(),
backendProvider: &fakeBackendProvider{
plugin: p,
},
@ -97,7 +97,7 @@ func TestInitializer_Initialize(t *testing.T) {
i := &Initializer{
cfg: &config.Cfg{},
log: log.NewNopLogger(),
log: log.NewTestLogger(),
backendProvider: &fakeBackendProvider{
plugin: p,
},
@ -120,7 +120,7 @@ func TestInitializer_Initialize(t *testing.T) {
i := &Initializer{
cfg: &config.Cfg{},
log: log.NewNopLogger(),
log: log.NewTestLogger(),
backendProvider: &fakeBackendProvider{
plugin: p,
},
@ -158,7 +158,7 @@ func TestInitializer_envVars(t *testing.T) {
},
},
license: licensing,
log: log.NewNopLogger(),
log: log.NewTestLogger(),
backendProvider: &fakeBackendProvider{
plugin: p,
},

View File

@ -12,12 +12,11 @@ import (
"strings"
"github.com/grafana/grafana/pkg/infra/fs"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/grafana/grafana/pkg/infra/slugify"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/config"
"github.com/grafana/grafana/pkg/plugins/logger"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/plugins/manager/loader/assetpath"
"github.com/grafana/grafana/pkg/plugins/manager/loader/finder"
"github.com/grafana/grafana/pkg/plugins/manager/loader/initializer"
@ -57,7 +56,7 @@ func ProvideService(cfg *config.Cfg, license plugins.Licensing, authorizer plugi
pluginRegistry registry.Service, backendProvider plugins.BackendFactoryProvider,
roleRegistry plugins.RoleRegistry, pluginsCDNService *pluginscdn.Service, assetPath *assetpath.Service) *Loader {
return New(cfg, license, authorizer, pluginRegistry, backendProvider, process.NewManager(pluginRegistry),
storage.FileSystem(logger.NewLogger("loader.fs"), cfg.PluginsPath), roleRegistry, pluginsCDNService, assetPath)
storage.FileSystem(log.NewPrettyLogger("loader.fs"), cfg.PluginsPath), roleRegistry, pluginsCDNService, assetPath)
}
func New(cfg *config.Cfg, license plugins.Licensing, authorizer plugins.PluginLoaderAuthorizer,

View File

@ -15,9 +15,9 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/infra/log/logtest"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/config"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/plugins/manager/fakes"
"github.com/grafana/grafana/pkg/plugins/manager/loader/initializer"
"github.com/grafana/grafana/pkg/plugins/manager/signature"
@ -570,7 +570,7 @@ func TestLoader_setDefaultNavURL(t *testing.T) {
},
}},
}
logger := &logtest.Fake{}
logger := log.NewTestLogger()
pluginWithDashboard.SetLogger(logger)
t.Run("Default nav URL is not set if dashboard UID field not is set", func(t *testing.T) {

View File

@ -6,9 +6,9 @@ import (
"sync"
"time"
"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/plugins/log"
"github.com/grafana/grafana/pkg/plugins/manager/registry"
)

View File

@ -5,10 +5,11 @@ import (
"sync"
"testing"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/plugins/log"
)
func TestProcessManager_Start(t *testing.T) {
@ -270,7 +271,7 @@ func createPlugin(t *testing.T, bp backendplugin.Plugin, cbs ...func(p *plugins.
},
}
p.SetLogger(log.NewNopLogger())
p.SetLogger(log.NewTestLogger())
p.RegisterClient(bp)
for _, cb := range cbs {

View File

@ -23,8 +23,8 @@ import (
// nolint:staticcheck
"golang.org/x/crypto/openpgp/clearsign"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/setting"
)

View File

@ -6,8 +6,8 @@ import (
"strings"
"testing"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/setting"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -151,7 +151,7 @@ func TestCalculate(t *testing.T) {
})
setting.AppUrl = tc.appURL
sig, err := Calculate(log.NewNopLogger(), &plugins.Plugin{
sig, err := Calculate(log.NewTestLogger(), &plugins.Plugin{
JSONData: plugins.JSONData{
ID: "test-datasource",
Info: plugins.Info{
@ -173,7 +173,7 @@ func TestCalculate(t *testing.T) {
})
runningWindows = true
sig, err := Calculate(log.NewNopLogger(), &plugins.Plugin{
sig, err := Calculate(log.NewTestLogger(), &plugins.Plugin{
JSONData: plugins.JSONData{
ID: "test-renderer",
Type: plugins.Renderer,

View File

@ -1,8 +1,8 @@
package signature
import (
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/log"
)
type Validator struct {

View File

@ -10,9 +10,9 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/infra/localcache"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/plugins/adapters"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/pluginsettings"
"github.com/grafana/grafana/pkg/services/user"

View File

@ -12,10 +12,11 @@ import (
"strings"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins/backendplugin"
"github.com/grafana/grafana/pkg/plugins/backendplugin/pluginextensionv2"
"github.com/grafana/grafana/pkg/plugins/backendplugin/secretsmanagerplugin"
"github.com/grafana/grafana/pkg/plugins/log"
"github.com/grafana/grafana/pkg/plugins/plugindef"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/util"

View File

@ -15,7 +15,7 @@ import (
"os"
"time"
"github.com/grafana/grafana/pkg/plugins/logger"
"github.com/grafana/grafana/pkg/plugins/log"
)
type Client struct {
@ -23,10 +23,10 @@ type Client struct {
httpClientNoTimeout http.Client
retryCount int
log logger.Logger
log log.PrettyLogger
}
func newClient(skipTLSVerify bool, logger logger.Logger) *Client {
func newClient(skipTLSVerify bool, logger log.PrettyLogger) *Client {
return &Client{
httpClient: makeHttpClient(skipTLSVerify, 10*time.Second),
httpClientNoTimeout: makeHttpClient(skipTLSVerify, 0),

View File

@ -8,22 +8,22 @@ import (
"path"
"strings"
"github.com/grafana/grafana/pkg/plugins/logger"
"github.com/grafana/grafana/pkg/plugins/log"
)
type Manager struct {
client *Client
baseURL string
log logger.Logger
log log.PrettyLogger
}
func ProvideService() *Manager {
defaultBaseURL := "https://grafana.com/api/plugins"
return New(false, defaultBaseURL, logger.NewLogger("plugin.repository"))
return New(false, defaultBaseURL, log.NewPrettyLogger("plugin.repository"))
}
func New(skipTLSVerify bool, baseURL string, logger logger.Logger) *Manager {
func New(skipTLSVerify bool, baseURL string, logger log.PrettyLogger) *Manager {
return &Manager{
client: newClient(skipTLSVerify, logger),
baseURL: baseURL,

View File

@ -14,7 +14,7 @@ import (
"strings"
"sync"
"github.com/grafana/grafana/pkg/plugins/logger"
"github.com/grafana/grafana/pkg/plugins/log"
)
var _ Manager = (*FS)(nil)
@ -30,10 +30,10 @@ type FS struct {
store map[string]string
mu sync.RWMutex
pluginsDir string
log logger.Logger
log log.PrettyLogger
}
func FileSystem(logger logger.Logger, pluginsDir string) *FS {
func FileSystem(logger log.PrettyLogger, pluginsDir string) *FS {
return &FS{
store: make(map[string]string),
pluginsDir: pluginsDir,

View File

@ -17,9 +17,9 @@ import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/components/simplejson"
"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/plugins/log"
"github.com/grafana/grafana/pkg/server"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/org"