From 90308248f68b8cddf0b01dd31a1b02a0f2899154 Mon Sep 17 00:00:00 2001 From: PJ Date: Tue, 16 Apr 2024 12:44:02 +0200 Subject: [PATCH] testing: default db logger --- internal/test/e2e/cluster.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/test/e2e/cluster.go b/internal/test/e2e/cluster.go index 1a47a4e9a..f77fa0922 100644 --- a/internal/test/e2e/cluster.go +++ b/internal/test/e2e/cluster.go @@ -32,6 +32,8 @@ import ( "lukechampine.com/frand" "go.sia.tech/renterd/worker" + gormlogger "gorm.io/gorm/logger" + "moul.io/zapgorm2" ) const ( @@ -240,6 +242,18 @@ func newTestCluster(t *testing.T, opts testClusterOptions) *TestCluster { apSettings = *opts.autopilotSettings } + // default database logger + if busCfg.DBLogger == nil { + busCfg.DBLogger = zapgorm2.Logger{ + ZapLogger: logger.Named("SQL"), + LogLevel: gormlogger.Warn, + SlowThreshold: 100 * time.Millisecond, + SkipCallerLookup: false, + IgnoreRecordNotFoundError: true, + Context: nil, + } + } + // Check if we are testing against an external database. If so, we create a // database with a random name first. uri, user, password, _ := stores.DBConfigFromEnv()