kit icon indicating copy to clipboard operation
kit copied to clipboard

StdLibAdapter doesn't correctly recognize panics from net/http when running a http server

Open luna-duclos opened this issue 9 years ago • 2 comments

When running a http server using the stdlib's net/http (the idiomatic way to do this in Go) and when using stdlog.SetOutput(log.NewStdlibAdapter(logger)), any panics recovered from by net/http and then printed out will be mangled. Only the top line will be shown in the msg field. Additionally, the file field is wrong.

luna-duclos avatar Apr 04 '16 11:04 luna-duclos

ts=2016-04-04T10:49:21Z caller=stdlib.go:89 file="http: panic serving 10.0.2.2:64629" 
 msg="runtime error: invalid memory address or nil pointer dereference"

peterbourgon avatar Apr 04 '16 11:04 peterbourgon

I am investigating a bit. Part of the problem is without including log.Lshortfile in the stdlib log flags the regexp in StdlibAdapter mistakes the "http: .... port" substring for a "file name:line number" string.

Capturing the multi-line stack trace is another problem.

ChrisHines avatar Apr 04 '16 17:04 ChrisHines