Skip to content

Commit

Permalink
refactor: Proper gin logging and mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Castell committed Oct 16, 2018
1 parent 39728d0 commit 1c64da4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dkron/log.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package dkron

import (
"github.com/sirupsen/logrus"
"io/ioutil"

"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)

var log = logrus.NewEntry(logrus.New())
Expand All @@ -20,5 +22,12 @@ func InitLogger(logLevel string, node string) {

formattedLogger.Level = level
log = logrus.NewEntry(formattedLogger).WithField("node", node)
gin.DefaultWriter = log.Writer()

if level == logrus.DebugLevel {
gin.DefaultWriter = log.Writer()
gin.SetMode(gin.DebugMode)
} else {
gin.DefaultWriter = ioutil.Discard
gin.SetMode(gin.ReleaseMode)
}
}

0 comments on commit 1c64da4

Please sign in to comment.