19 lines
335 B
Go
19 lines
335 B
Go
package log
|
|
|
|
import (
|
|
"go.uber.org/zap"
|
|
"gorm.io/gorm/logger"
|
|
"moul.io/zapgorm2"
|
|
)
|
|
|
|
func GormZapLogger(debug bool) logger.Interface {
|
|
l := zapgorm2.New(zap.L())
|
|
if !debug {
|
|
l.LogLevel = -1
|
|
} else {
|
|
l.LogLevel = logger.Info
|
|
}
|
|
l.SetAsDefault() // optional: configure gorm to use this zapgorm.Logger for callbacks
|
|
return l
|
|
}
|