Description
Currently there are difficulties with nicely capturing crash output from Go programs. Crashes print to stderr, however, usually both stdout and stderr are used by programs for other purposes. While it's not wrong to output it to stderr, it mixes two outputs together making later separation more difficult.
Capturing crashes is useful for post-mortem debugging and sending reports. Of course, due to unknown crashed program state using a custom callback is understandably dangerous.
A simpler alternative would be to allow changing file descriptor where to print crashes. In the simplest form it could look like:
package main
import "runtime/debug"
func init(){
debug.SetCrashOutputFD(3)
}
This would allow passing in a fd
for separate file, pipe to another "crash monitor" process or connect to an external server. Of course there's a slight possibility of write
taking a long time, when passing in a pipe/connection slowing down the crashing of the program.
With regards to naming it could also be SetCrashFD
, SetTracebackFD
or SetTracebackOutputFD
.