Skip to content
/ gormzap Public
forked from hypnoglow/gormzap

GORM logger implementation using Uber's zap ⚡

License

Notifications You must be signed in to change notification settings

WeeraW/gormzap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gormzap

GoDoc CircleCI GitHub release License MIT

GORM logger implementation using zap.

Usage

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)))

About

GORM logger implementation using Uber's zap ⚡

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 96.7%
  • AMPL 3.3%