رفتن به محتوا

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