GORM (v1) logger implementation using Uber's zap
MIT License
GORM logger implementation using zap.
var debug bool // shows if we have debug enabled in our app
db, err := gorm.Open("postgres", dsn)
if err != nil {
panic(err)
}
if debug {
// By default, gorm logs only errors. If we set LogMode to true,
// then all queries will be logged.
// WARNING: if you explicitly set this to false, then even
// errors won't be logged.
db.LogMode(true)
}
log := zap.NewExample()
db.SetLogger(gormzap.New(log, gormzap.WithLevel(zap.DebugLevel)))