@@ -8,6 +8,30 @@ import (
88 "github.com/labstack/echo/v4"
99)
1010
11+ // Example for `slog` https://pkg.go.dev/log/slog
12+ // logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
13+ // e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
14+ // LogStatus: true,
15+ // LogURI: true,
16+ // LogError: true,
17+ // HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code
18+ // LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error {
19+ // if v.Error == nil {
20+ // logger.LogAttrs(context.Background(), slog.LevelInfo, "REQUEST",
21+ // slog.String("uri", v.URI),
22+ // slog.Int("status", v.Status),
23+ // )
24+ // } else {
25+ // logger.LogAttrs(context.Background(), slog.LevelError, "REQUEST_ERROR",
26+ // slog.String("uri", v.URI),
27+ // slog.Int("status", v.Status),
28+ // slog.String("err", v.Error.Error()),
29+ // )
30+ // }
31+ // return nil
32+ // },
33+ // }))
34+ //
1135// Example for `fmt.Printf`
1236// e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{
1337// LogStatus: true,
0 commit comments