Skip to content

Commit

Permalink
Added log context
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-skalicky committed Jul 12, 2024
1 parent ef48220 commit a6d7aa4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions management/server/sql_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ func NewSqliteStore(ctx context.Context, dataDir string, metrics telemetry.AppMe
}

file := filepath.Join(dataDir, storeStr)
db, err := gorm.Open(sqlite.Open(file), getGormConfig())
db, err := gorm.Open(sqlite.Open(file), getGormConfig(ctx))
if err != nil {
return nil, err
}
Expand All @@ -672,7 +672,7 @@ func NewSqliteStore(ctx context.Context, dataDir string, metrics telemetry.AppMe

// NewPostgresqlStore creates a new Postgres store.
func NewPostgresqlStore(ctx context.Context, dsn string, metrics telemetry.AppMetrics) (*SqlStore, error) {
db, err := gorm.Open(postgres.Open(dsn), getGormConfig())
db, err := gorm.Open(postgres.Open(dsn), getGormConfig(ctx))

if err != nil {
return nil, err
Expand All @@ -683,9 +683,9 @@ func NewPostgresqlStore(ctx context.Context, dsn string, metrics telemetry.AppMe
return NewSqlStore(ctx, db, PostgresStoreEngine, metrics)
}

func getGormConfig() *gorm.Config {
log.WithContext(context.Background()).Info("Setting up GORM logger")
sql_logger := logger.New(log.WithContext(context.Background()), logger.Config{
func getGormConfig(ctx context.Context) *gorm.Config {
log.WithContext(ctx).Info("Setting up GORM logger")
sql_logger := logger.New(log.WithContext(ctx), logger.Config{
SlowThreshold: 1*time.Second,
LogLevel: logger.Info,
Colorful: false,
Expand Down

0 comments on commit a6d7aa4

Please sign in to comment.