viper-app/pkg/log/gorm.go

16 lines
330 B
Go
Raw Normal View History

2023-02-03 16:18:31 +08:00
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 {
2023-02-03 16:18:31 +08:00
l := zapgorm2.New(zap.L())
l.SetAsDefault() // optional: configure gorm to use this zapgorm.Logger for callbacks
l.LogLevel = gormLogger.Info
return l
}