Skip to content

Commit

Permalink
chore: use zapgorm for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Sep 23, 2018
1 parent 19d4281 commit c53babb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/denisenkom/go-mssqldb v0.0.0-20180901172138-1eb28afdf9b6 // indirect
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/gilliek/go-opml v1.0.0
github.com/go-sql-driver/mysql v1.4.0 // indirect
github.com/golang/protobuf v1.2.0 // indirect
github.com/google/go-cmp v0.2.0 // indirect
Expand All @@ -24,17 +23,13 @@ require (
github.com/mitchellh/mapstructure v1.0.0 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/pkg/errors v0.8.0
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.1.1 // indirect
github.com/spf13/cast v1.2.0 // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/jwalterweatherman v0.0.0-20180814060501-14d3d4c51834 // indirect
github.com/spf13/pflag v1.0.2
github.com/spf13/viper v1.1.0
github.com/stretchr/testify v1.2.2 // indirect
github.com/xanzy/go-gitlab v0.11.0
go.uber.org/atomic v1.3.2 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.9.1
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b // indirect
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d // indirect
Expand All @@ -44,4 +39,5 @@ require (
golang.org/x/text v0.3.0 // indirect
google.golang.org/appengine v1.1.0 // indirect
gopkg.in/yaml.v2 v2.2.1 // indirect
moul.io/zapgorm v0.0.0-20180923113722-8436a28d1214
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DP
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gilliek/go-opml v1.0.0 h1:X8xVjtySRXU/x6KvaiXkn7OV3a4DHqxY8Rpv6U/JvCY=
github.com/gilliek/go-opml v1.0.0/go.mod h1:fOxmtlzyBvUjU6bjpdjyxCGlWz+pgtAHrHf/xRZl3lk=
github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
Expand Down Expand Up @@ -88,3 +86,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
moul.io/zapgorm v0.0.0-20180923113722-8436a28d1214 h1:V4TfvG+c1sfyT72B/s+qc4qOxtwcZ9HG2yFxgu5/jaw=
moul.io/zapgorm v0.0.0-20180923113722-8436a28d1214/go.mod h1:5XkuYCrMvJcscMD3+T4QGDaWsCZiql8k2Pv5iNhTB/g=
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/spf13/viper"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"moul.io/zapgorm"
)

func main() {
Expand Down Expand Up @@ -74,6 +75,7 @@ func newRootCommand() *cobra.Command {
if err != nil {
return err
}
db.SetLogger(zapgorm.New(zap.L().Named("vendor.gorm")))
db = db.Set("gorm:auto_preload", true)
db = db.Set("gorm:association_autoupdate", true)
db.BlockGlobalUpdate(true)
Expand All @@ -86,7 +88,6 @@ func newRootCommand() *cobra.Command {
).Error; err != nil {
return err
}
fmt.Println(dbPath, db)

return nil
}
Expand Down

0 comments on commit c53babb

Please sign in to comment.