I'm trying to develop using Gin, and I keep getting this warning
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production
I don't care, and it is cluttering up my log, so I can't see the real errors. Is there a way to disable this "feature"?
It tell us: now debug mode and how switch release mode.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
Yeah, but you pretty much know when you're in debug mode, and you can google how to get to production mode. It is one more garbage thing you have to ignore when you're developing. At least make it an option to disable it.
It is just as the option to suppress debugging logs -- gin.SetMode(gin.ReleaseMode). You can use this to ignore logs.
Or you just grep -v to ignore specific ones.
go run /tmp/test.go 2>&1 | egrep -v 'Running in "debug" mode|using (env|code)'
gin shows various debugging logs and it is not good to add an option to ignore each log individually...
if you want to close tips of debug warning ,use this in your beginning
gin.SetMode(gin.ReleaseMode)
if you want to close logger middleware ,example :
[GIN] 2018/05/08 - 18:38:00 | 200 | 25.0676ms | x.x.x.x | GET xxxxx/xxxx/xxx
use below to init a router:
router := gin.New()
router.Use(gin.Recovery())
You can suppress the debug warning by overwriting the os.Stderr file descriptor temporarily before starting Gin, and then restoring it:
stderr := os.Stderr
fd, _ := os.Open(os.DevNull)
os.Stderr = fd
r := gin.New()
os.Stderr = stderr
This will redirect Gin's debug mode message to /dev/null, essentially discarding it.
Warning: If Gin fails to create an engine, the errors will not be shown. Use this at your own risk.
Fixed in #1891 (gin 1.5.0)
Might be a side feature which unlikely to go through but I wonder if instead of:
I'm trying to develop using Gin, and I keep getting this warning
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production
I don't care, and it is cluttering up my log, so I can't see the real errors. Is there a way to disable this "feature"?
We can just log this warning once through out one application lifecycle.
Most helpful comment
It tell us: now debug mode and how switch release mode.