tinkerbell / hegel

Instance Metadata Service
https://tinkerbell.org
Apache License 2.0
98 stars 33 forks source link

Middleware logger makes it difficult to debug #348

Open jacobweinstock opened 6 months ago

jacobweinstock commented 6 months ago

Currently handlers use ctx.AbortWithError to return errors. The logger in middleware (https://github.com/tinkerbell/hegel/blob/d74d351c3f6643a98247884f08850a0ed1368b06/internal/logger/logger.go#L14) then handles logging error messages. This causes all log lines to report the same caller location. hegel/internal/logger/logger.go:53 https://github.com/tinkerbell/hegel/blob/d74d351c3f6643a98247884f08850a0ed1368b06/internal/logger/logger.go#L53

This makes debugging challenging and logging of the caller pointless.

Expected Behaviour

Current Behaviour

Possible Solution

One option could be to pass a logger into all handlers. I'm certain there are are others but i'll need to dig into the code and this space mentally a bit more.

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

Your Environment