viper-app/pkg/log/gorm.go
2023-02-03 16:18:31 +08:00

16 lines
318 B
Go

package log
import (
"go.uber.org/zap"
"gorm.io/gorm/logger"
gormLogger "gorm.io/gorm/logger"
"moul.io/zapgorm2"
)
func GormZapLogger() 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
}