-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
Description
Question Description
The Fiber v3 version provides a log package. When the project is initialized, the RequestID middleware is used. Why isn't the request-id carried by default in the log.WithContext(ctx)? Currently, it looks like log.WithContext(ctx).Info and log.Info are the same.
Code Snippet (optional)
package main
import (
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/log"
"github.com/gofiber/fiber/v3/middleware/requestid"
)
func main() {
app := fiber.New()
app.Use(requestid.New())
app.Get("/", func(c fiber.Ctx) error {
log.WithContext(c).Info("start...")
// 模拟业务逻辑调用
businessLogic(c)
log.WithContext(c).Info("end...")
return c.SendString("Hello, Fiber!")
})
log.Fatal(app.Listen(":3000"))
}
func businessLogic(c fiber.Ctx) {
log.WithContext(c).Debug("businessLogic...")
}Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my questions prior to opening this one.
- I understand that improperly formatted questions may be closed without explanation.