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"
|
|
|
|
)
|
|
|
|
|
2023-05-13 00:55:47 +08:00
|
|
|
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
|
|
|
|
}
|