viper-app/pkg/log/gorm.go

16 lines
330 B
Go

package log
import (
"go.uber.org/zap"
"gorm.io/gorm/logger"
gormLogger "gorm.io/gorm/logger"
"moul.io/zapgorm2"
)
func GormZapLogger(level string) logger.Interface {
l := zapgorm2.New(zap.L())
l.SetAsDefault() // optional: configure gorm to use this zapgorm.Logger for callbacks
l.LogLevel = gormLogger.Info
return l
}