samber / slog-gin

🚨 Gin middleware for slog logger
https://pkg.go.dev/github.com/samber/slog-gin
MIT License
89 stars 13 forks source link

[Question] repeated time field #10

Closed changsheng1239 closed 6 months ago

changsheng1239 commented 7 months ago

Just a question, is the repeated time field expected ? is there a good way to dedup it ?

{"time":"2023-12-05T10:06:36.064636242Z","level":"INFO","msg":"Incoming request","status":200,"method":"GET","path":"/","route":"/","ip":"127.0.0.1","latency":5993833,"time":"2023-12-05T10:06:36.064615629Z"}
hakwik commented 6 months ago

I experience the same thing. I have not yet figured out how to disable the second time field in the logs.

Edit: I opened a PR to hopefully be able to configure this (and some other options).

samber commented 6 months ago

Discussed here: https://github.com/samber/slog-echo/issues/16

samber commented 6 months ago

Closing, since we changed the record format:

{
    "time": "xyz",   // from handler
    "request": {
        "time": "xyz", // request time, from middleware
        "path": "/hello/world",
        ...
    },
    "response": {
        "time": "xyz", // response time, from middleware
        "duration": "10ms",
        "status": 200,
        ...
    },
    ...
}