gin-logrus is a gin middleware implemented using logrus
go get github.com/RuiFG/gin-logrus
func main() {
engine := gin.New()
engine.Use(gin_logrus.Logger())
engine.GET("", func(context *gin.Context) {
context.Status(200)
})
_ = engine.Run("127.0.0.1:8080")
}
You can also define the implementation of LogTransformer yourself
func main() {
logger := logrus.New()
engine := gin.New()
engine.Use(gin_logrus.LoggerWithConfig(gin_logrus.LoggerConfig{
Logger: logger,
Formatter: func(logger *logrus.Logger, params gin_logrus.FieldsParams) {
//noting to do
}}))
engine.GET("", func(context *gin.Context) {
context.Status(200)
})
_ = engine.Run("127.0.0.1:8080")
}
This project is under MIT License. See the LICENSE file for the full license text.