Documentation ¶
Overview ¶
Package panicwatch guarantees you that you will never miss a panic. Use it to reliably log any unhandled panics that may occur in your application. This is completely transparent to your application, and it doesn't affect it in any way. All signal handling and file descriptor manipulation (either from inside or outside) is still under your control.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
Start validates panicwatch config, replaces the stderr file descriptor with a new one and starts a watcher process. This watcher process will read the original stderr and tee it into the replaced file descriptor. When the application exits, the watcher process will check if there was a panic in the original stderr. If yes, it will call the OnPanic callback. If the watcher process encounters an error or dies, then appropriate callback is called if configured.
Types ¶
type Config ¶
type Config struct { // BufferSize specifies the size of the read buffer between dup-ed stderr and the real one. Optional/ BufferSize int // PanicDetectorBufferSize specifies the size of the buffer used to detect panic. // Too low value will cause the detection to fail. Optional. PanicDetectorBufferSize int // OnPanic is a callback that will be called after your application dies, if a panic is detected. Required. OnPanic func(Panic) // OnWatcherErr is a callback that will be called when watcher process encounters an error. Optional. OnWatcherError func(error) // OnWatcherDied is a callback that will be called when watcher process dies. // It is recommended to set this callback to shut down your application gracefully. Optional. OnWatcherDied func(error) }
Config holds the configuration of panicwatch.
type Panic ¶
Panic holds information about a panic parsed from stderr of your application.