-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ v3 (feature): refactor logger middleware #1979
Conversation
efectn
commented
Jul 18, 2022
- Make middleware extandable for 3rd-party loggers. (🚀 v3 Request: Numerous Minor Enchancements #1828)
- Make middleware extandable for 3rd-party loggers. (#1828)
- Make middleware extandable for 3rd-party loggers. (#1828)
What is the point of keeping the existing logger function in a new |
Zerolog example: package main
import (
"os"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/logger"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func main() {
app := fiber.New()
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
app.Use(logger.New(logger.Config{LoggerFunc: func(c fiber.Ctx, data logger.LoggerData, cfg logger.Config) error {
log.Info().
Str("path", c.Path()).
Str("method", c.Method()).
Int("status", c.Response().
StatusCode()).
Msg("new request")
return nil
}}))
app.Get("/", func(c fiber.Ctx) error {
return c.SendString("test")
})
app.Listen(":3000")
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need some work on benchmarks to proceed
- add example for zerolog.