labstack / echo

High performance, minimalist Go web framework

Home Page:https://echo.labstack.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DefaultHTTPErrorHandler does not log

linglingqi007 opened this issue · comments

Issue Description

DefaultHTTPErrorHandler does not record the err returned by handler

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

image

Actual behaviour

No errors logged
image

Steps to reproduce

Returns an error in the handler

Working code to debug

package main

func main() {
    e := echo.New()
    e.GET("/", func(ctx echo.Context) error {
        return fmt.Errorf("hello")
    })
    e.Start(":7123")
}

Version/commit

v4.11.4

DefaultHTTPErrorHandler is not meant to log errors. It is meant to send error responses. It logs errors only for cases when writing the response failed. To log errors use:

DefaultHTTPErrorHandler is not meant to log errors. It is meant to send error responses. It logs errors only for cases when writing the response failed. To log errors use:

The feeling of documentation can be misleading.
image

image

The other part of the tutorial documents both the ERR returned by the handler and the ERR that ultimately sends the response.

But it's actually as you said,It logs errors only for cases when writing the response failed.

I will take a look at Echo docs and see if I can improve things.

Notes for other readers in future: