Plugins: Replace references of plugin SDK backend.Logger with Grafana logger (#95235)

replace references
This commit is contained in:
Will Browne 2024-10-24 12:00:40 +01:00 committed by GitHub
parent 26fab52086
commit a2868fdb14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 9 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/grafana/dskit/instrument"
"github.com/grafana/dskit/middleware"
"github.com/grafana/grafana-plugin-sdk-go/backend"
grpcAuth "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/auth"
"github.com/prometheus/client_golang/prometheus"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
@ -118,14 +117,14 @@ func (s *gPRCServerService) Run(ctx context.Context) error {
s.logger.Info("GRPC server: starting")
err := s.server.Serve(listener)
if err != nil {
backend.Logger.Error("GRPC server: failed to serve", "err", err)
s.logger.Error("GRPC server: failed to serve", "err", err)
serveErr <- err
}
}()
select {
case err := <-serveErr:
backend.Logger.Error("GRPC server: failed to serve", "err", err)
s.logger.Error("GRPC server: failed to serve", "err", err)
return err
case <-ctx.Done():
}

View File

@ -14,6 +14,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/kinds/dataquery"
"github.com/grafana/grafana/pkg/tsdb/azuremonitor/types"
"github.com/stretchr/testify/require"
@ -1150,7 +1151,7 @@ func TestBuildAppInsightsQuery(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
query, err := buildAppInsightsQuery(ctx, tt.queryModel, dsInfo, appInsightsRegExp, backend.Logger)
query, err := buildAppInsightsQuery(ctx, tt.queryModel, dsInfo, appInsightsRegExp, log.NewNullLogger())
tt.Err(t, err)
if diff := cmp.Diff(&tt.azureLogAnalyticsQuery, query); diff != "" {
t.Errorf("Result mismatch (-want +got): \n%s", diff)

View File

@ -163,7 +163,7 @@ func (e *AzureResourceGraphDatasource) executeQuery(ctx context.Context, query *
defer func() {
if err := res.Body.Close(); err != nil {
backend.Logger.Warn("Failed to close response body", "err", err)
e.Logger.Warn("Failed to close response body", "err", err)
}
}()

View File

@ -90,7 +90,7 @@ func doRequestPage(_ context.Context, r *http.Request, dsInfo datasourceInfo, pa
defer func() {
if err = res.Body.Close(); err != nil {
backend.Logger.Warn("Failed to close response body", "error", err)
logger.Warn("Failed to close response body", "error", err)
}
}()

View File

@ -33,7 +33,7 @@ func (l fakeLogger) With(args ...interface{}) log.Logger {
func TestConfigureAzureAuthentication(t *testing.T) {
azureSettings := &azsettings.AzureSettings{}
testLogger := backend.Logger
testLogger := log.NewNullLogger()
t.Run("should set Azure middleware when JsonData contains valid credentials", func(t *testing.T) {
settings := backend.DataSourceInstanceSettings{

View File

@ -7,6 +7,7 @@ import (
"github.com/grafana/grafana-azure-sdk-go/v2/azsettings"
"github.com/grafana/grafana-plugin-sdk-go/backend"
sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
"github.com/stretchr/testify/require"
)
@ -28,7 +29,7 @@ func TestExtendClientOpts(t *testing.T) {
}
ctx := backend.WithGrafanaConfig(context.Background(), cfg)
opts := &sdkhttpclient.Options{}
err := extendClientOpts(ctx, settings, opts, backend.Logger)
err := extendClientOpts(ctx, settings, opts, log.NewNullLogger())
require.NoError(t, err)
require.Equal(t, 1, len(opts.Middlewares))
})
@ -47,7 +48,7 @@ func TestExtendClientOpts(t *testing.T) {
SecretKey: "secretkey",
},
}
err := extendClientOpts(context.Background(), settings, opts, backend.Logger)
err := extendClientOpts(context.Background(), settings, opts, log.NewNullLogger())
require.NoError(t, err)
require.Equal(t, "aps", opts.SigV4.Service)
})