set gin mode before router initialization

this was previously set after the router was created, causing a debug
message every start.
pull/20/head
Harvey Tindall 5 years ago
parent abc51f2443
commit 151062fbc1
No known key found for this signature in database
GPG Key ID: BBC65952848FB1A2

@ -82,7 +82,6 @@ func setGinLogger(router *gin.Engine, debugMode bool) {
}(),
)
}))
gin.SetMode(gin.DebugMode)
} else {
router.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
return fmt.Sprintf("[GIN] %s(%s) => %d\n",
@ -91,7 +90,6 @@ func setGinLogger(router *gin.Engine, debugMode bool) {
param.StatusCode,
)
}))
gin.SetMode(gin.ReleaseMode)
}
}
@ -286,11 +284,15 @@ func main() {
}
} else {
debugMode = false
gin.SetMode(gin.ReleaseMode)
address = "0.0.0.0:8056"
}
app.info.Println("Loading routes")
if debugMode {
gin.SetMode(gin.DebugMode)
} else {
gin.SetMode(gin.ReleaseMode)
}
router := gin.New()
setGinLogger(router, debugMode)

Loading…
Cancel
Save