Closed varunshoor closed 11 months ago
I think its because the code seems to reference config.ClientErrorLevel
when it should use config.ServerErrorLevel
?
switch {
case c.Response().StatusCode() >= http.StatusBadRequest && c.Response().StatusCode() < http.StatusInternalServerError:
logger.LogAttrs(context.Background(), config.ClientErrorLevel, err.Error(), attributes...)
case c.Response().StatusCode() >= http.StatusInternalServerError:
logger.LogAttrs(context.Background(), config.ServerErrorLevel, err.Error(), attributes...)
Scratch that, it seems to be because of c.Error(), changing it to a string seems to fix it. Whats the suggested next step? I don't want to send a PR when I don't know what I am doing
Ok, thanks for reporting this issue.
I just made a fix -> v1.1.1
I am sorry for reopening this but there is a regression. The 400 status code panic seems to have been resolved but now 200 status code requests just return "OK". Is it possible that the call to fiber.NewError() when err == nil resets the output chain?
Hi, I encountered the same problem, where I define the response status as error type without returning an error value. In this case I think “err” is nil
The fix in the latest version causes an error to be generated even if the route handler did not originally create it. This causes the ErrorHandler (whether default or custom) to also handle the request, which otherwise would not happen. I created a fix in PR-5. This should solve the dual management problem. In the case of responses genuinely managed by the ErrorHandler, however, the logs are created before the response has an error status, therefore they appear with a status of 200
slog-fiber seems to panic when using 404 middleware and sending requests to non existent routes.
Steps to reproduce:
slog-fiber
using the above codeOutput:
I am still learning Go so not sure how to fix this