Controlling Log output coloring
By default, logs output on console should be colorized depending on the detected TTY.
Never colorize logs:
func main() {
// Disable log's color
gin.DisableConsoleColor()
// Creates a gin router with default middleware:
// logger and recovery (crash-free) middleware
router := gin.Default()
router.GET("/ping", func(c *gin.Context) {
c.String(200, "pong")
})
router.Run(":8080")
}
Always colorize logs:
func main() {
// Force log's color
gin.ForceConsoleColor()
// Creates a gin router with default middleware:
// logger and recovery (crash-free) middleware
router := gin.Default()
router.GET("/ping", func(c *gin.Context) {
c.String(200, "pong")
})
router.Run(":8080")
}
Last modified March 7, 2020 : add blog dir (#115) (f46734b)