diff --git a/pkg/interceptors/database_logging.go b/pkg/interceptors/database_logging.go index 29814202..18273390 100644 --- a/pkg/interceptors/database_logging.go +++ b/pkg/interceptors/database_logging.go @@ -4,11 +4,12 @@ import ( "context" grpcmiddleware "github.com/grpc-ecosystem/go-grpc-middleware" + "google.golang.org/grpc" + "gorm.io/gorm" + sdkdatabasecontext "github.com/scribd/go-sdk/pkg/context/database" sdkloggercontext "github.com/scribd/go-sdk/pkg/context/logger" sdklogger "github.com/scribd/go-sdk/pkg/logger" - "google.golang.org/grpc" - "gorm.io/gorm" ) // DatabaseLoggingUnaryServerInterceptor returns a unary server interceptor. diff --git a/pkg/interceptors/database_logging_test.go b/pkg/interceptors/database_logging_test.go index 4d5b9352..4939143d 100644 --- a/pkg/interceptors/database_logging_test.go +++ b/pkg/interceptors/database_logging_test.go @@ -10,9 +10,6 @@ import ( "path" "testing" - sdktesting "github.com/scribd/go-sdk/pkg/testing" - "github.com/scribd/go-sdk/pkg/logger" - "github.com/scribd/go-sdk/pkg/testing/testproto" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc" @@ -21,6 +18,10 @@ import ( "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/mocktracer" "gorm.io/driver/sqlite" "gorm.io/gorm" + + "github.com/scribd/go-sdk/pkg/logger" + sdktesting "github.com/scribd/go-sdk/pkg/testing" + "github.com/scribd/go-sdk/pkg/testing/testproto" ) type TestRecord struct { @@ -194,7 +195,6 @@ func checkGormLoggerFields(t *testing.T, fields map[string]interface{}) { assert.True(t, ok, "%s not found in log fields", logger.GormTraceFieldKey) assert.NotEmpty(t, dbFields) - assert.NotEmpty(t, dbFields["elapsed seconds"]) assert.NotEmpty(t, dbFields["affected rows"]) assert.NotEmpty(t, dbFields["sql"]) diff --git a/pkg/logger/gorm.go b/pkg/logger/gorm.go index 43906b0a..60e38afa 100644 --- a/pkg/logger/gorm.go +++ b/pkg/logger/gorm.go @@ -51,7 +51,7 @@ func (g gormLogger) Trace(ctx context.Context, begin time.Time, fc func() (strin tracingLogger := g.logger.WithFields(Fields{ GormTraceFieldKey: Fields{ "elapsed seconds": time.Since(begin).Seconds(), - "affected rows": rows, + "affected rows": rows, "sql": sql, }, }) diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 37591ead..3e268b8a 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -4,7 +4,6 @@ package logger import ( - "github.com/sirupsen/logrus" ) diff --git a/pkg/middleware/database_logging.go b/pkg/middleware/database_logging.go index 8a0709a8..8f35b27d 100644 --- a/pkg/middleware/database_logging.go +++ b/pkg/middleware/database_logging.go @@ -3,10 +3,11 @@ package middleware import ( "net/http" + "gorm.io/gorm" + sdkdatabasecontext "github.com/scribd/go-sdk/pkg/context/database" sdkloggercontext "github.com/scribd/go-sdk/pkg/context/logger" sdklogger "github.com/scribd/go-sdk/pkg/logger" - "gorm.io/gorm" ) // DatabaseLoggingMiddleware wraps an instantiated sdk.Logger that will be injected