Is your feature request related to a problem? Please describe.
I'm not sure if there were any plans to write your own logger (as middleware?), but it would be very cool to add a logger from Uber โ zap. It's blazing fast, structured, leveled logging system.
Describe the solution you'd like
For one of my side project (Create Go App, to be exact), I created web app template for Fiber with example usage of zap logger:
Describe alternatives you've considered
As alternative solution, I know only Logrus, but he's very slow and doesn't have flexible structure for configuring (_really, when I read zap's docs and source code, I found every things, which I wanted to re-configure_).
Therefore, I don't recommend to use Logrus for Fiber, but good to know! ๐
Additional context
I'm ready to discus about this various feature for every web frameworks and may (want) help to write logger middleware, if needed. Please, let me know what you think!
@koddr, great suggestion. I'm not home right now but I want to finish the middleware structure tomorrow so we can start writing many midware apps.
Regarding the logger idea, it looks like a good tool. I would like a morgan like system for fiber.
I will continue tonight to get the middleware package ready for development.
Middleware plans for feb
I have created a simple logger https://github.com/gofiber/fiber/blob/master/middleware/morgan.go, this is just an example on how internal middlewares are build up.
package main
import (
"github.com/gofiber/fiber"
"github.com/gofiber/fiber/middleware"
)
func main() {
app := fiber.New()
app.Use(middleware.Morgan())
// app.Use(middleware.Cors())
// app.Use(middleware.Helmet())
// app.Use(middleware.Session())
// app.Use(middleware.CSurf())
// app.Use(middleware.Limiter())
// etc...
app.Get("/", func(c *fiber.Ctx) {
c.Send("Hello, World!")
})
app.Listen(3000)
}

I would like to replicate the following express middlewares for fiber this month:
middleware.Morgan https://github.com/expressjs/morganmiddleware.Session https://github.com/expressjs/sessionmiddleware.Cors https://github.com/expressjs/corsmiddleware.CSurf https://github.com/expressjs/csurfmiddleware.Limiter https://github.com/nfriedly/express-rate-limit@Fenny wow, it's good point ๐
One little question about naming of logger: _can we change/symlinked it?_ I mean, Morgan for logger it's okay, but not really (for some people, who doesn't know Node.js ecosystem).
Would be great and more understandable โ re-name Morgan to Logger and hide info (like _easter egg_) about it to comments into middleware file ./middleware/logger.go OR create _symlink_ to this function (to have access to both Morgan() and Logger()), If you want to keep this naming.
I know, you have good Node.js background, but sometimes, similar naming (without fallback to understandable) is huge trouble to promote project to all layers of coders around the programming languages (and stacks).
Please, think about it ๐
Agreed :+1:
Most helpful comment
I have created a simple logger https://github.com/gofiber/fiber/blob/master/middleware/morgan.go, this is just an example on how internal middlewares are build up.
I would like to replicate the following express middlewares for fiber this month:
middleware.Morganhttps://github.com/expressjs/morganmiddleware.Sessionhttps://github.com/expressjs/sessionmiddleware.Corshttps://github.com/expressjs/corsmiddleware.CSurfhttps://github.com/expressjs/csurfmiddleware.Limiterhttps://github.com/nfriedly/express-rate-limit