feature(manager): add contextErrorLogger middleware

This commit is contained in:
walkerning 2016-04-25 10:47:13 +08:00 committed by bigeagle
parent 4ea26921e7
commit 02bb8c16ab
No known key found for this signature in database
GPG Key ID: 9171A4571C27920A

16
manager/middleware.go Normal file
View File

@ -0,0 +1,16 @@
package manager
import (
"github.com/gin-gonic/gin"
)
func contextErrorLogger(c *gin.Context) {
errs := c.Errors.ByType(gin.ErrorTypeAny)
if len(errs) > 0 {
for _, err := range errs {
logger.Error(`"in request "%s %s: %s"`, c.Request.Method, c.Request.URL.Path, err.Error())
}
}
// pass on to the next middleware in chain
c.Next()
}