Commit 05c4dd99 authored by Cloud User's avatar Cloud User

debug http log

parent f8c6577a
...@@ -894,25 +894,29 @@ func main() { ...@@ -894,25 +894,29 @@ func main() {
// Create a new instance of the Fiber web framework. // Create a new instance of the Fiber web framework.
app := fiber.New() app := fiber.New()
cfg := slogfiber.Config{ // cfg := slogfiber.Config{
WithUserAgent: true, // DefaultLevel: slog.LevelInfo,
WithRequestID: true, // ClientErrorLevel: slog.LevelWarn,
WithRequestBody: true, // ServerErrorLevel: slog.LevelError,
WithRequestHeader: true,
WithResponseBody: false,
WithResponseHeader: true,
WithSpanID: true,
WithTraceID: true,
//DefaultLevel: levelVar.Level(),
DefaultLevel: slog.LevelInfo,
ClientErrorLevel: slog.LevelWarn,
ServerErrorLevel: slog.LevelError,
}
_ = cfg // WithUserAgent: false,
// WithRequestID: false,
// WithRequestBody: false,
// WithRequestHeader: true,
// WithResponseBody: false,
// WithResponseHeader: false,
// WithSpanID: false,
// WithTraceID: false,
// //Filters: []Filter{},
// }
//_ = cfg
//app := fiber.New() //app := fiber.New()
app.Use(slogfiber.NewWithConfig(slog.Default(), cfg)) //app.Use(slogfiber.NewWithConfig(slog.Default(), cfg))
app.Use(slogfiber.New(slog.Default()))
//app.Use(recover.New())
//app.Use(slogfiber.New(slog.Default())) //app.Use(slogfiber.New(slog.Default()))
app.Use(recover.New()) app.Use(recover.New())
...@@ -921,7 +925,7 @@ func main() { ...@@ -921,7 +925,7 @@ func main() {
jwtGroup := app.Group("/jwt") jwtGroup := app.Group("/jwt")
apiGroupV1 := apiGroup.Group("/v1") apiGroupV1 := apiGroup.Group("/v1")
apiGroupV1.Post("/*", slogfiber.NewWithConfig(slog.Default(), cfg), ApiOrJWT) apiGroupV1.Post("/*", ApiOrJWT)
jwtGroupV1 := jwtGroup.Group("/v1") jwtGroupV1 := jwtGroup.Group("/v1")
jwtGroupV1.Post("/*", ApiOrJWT) jwtGroupV1.Post("/*", ApiOrJWT)
...@@ -959,9 +963,24 @@ func main() { ...@@ -959,9 +963,24 @@ func main() {
return c.SendString(fmt.Sprintf("can not find out the task id %s in result cache.", taskId)) return c.SendString(fmt.Sprintf("can not find out the task id %s in result cache.", taskId))
}) })
cfg := slogfiber.Config{
WithUserAgent: true,
WithRequestID: true,
WithRequestBody: true,
WithRequestHeader: true,
WithResponseBody: true,
WithResponseHeader: true,
WithSpanID: true,
WithTraceID: true,
//DefaultLevel: levelVar.Level(),
DefaultLevel: slog.LevelInfo,
ClientErrorLevel: slog.LevelWarn,
ServerErrorLevel: slog.LevelError,
}
callbackGroup := app.Group("/callback") callbackGroup := app.Group("/callback")
callbackGroupV1 := callbackGroup.Group("/v1") callbackGroupV1 := callbackGroup.Group("/v1")
callbackGroupV1.Post("/", func(c *fiber.Ctx) error { callbackGroupV1.Post("/", slogfiber.NewWithConfig(slog.Default(), cfg), func(c *fiber.Ctx) error {
slog.LogAttrs(c.UserContext(), slog.LevelInfo, "callback", slog.String("path", c.Route().Path)) slog.LogAttrs(c.UserContext(), slog.LevelInfo, "callback", slog.String("path", c.Route().Path))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment