Commit Graph

7 Commits

Author SHA1 Message Date
Albert Salim 4346c76f26 Remove unnecessary wrapper function on `os.Exit` 2018-10-10 21:57:58 +08:00
Albert Salim 99bc300c8d Add a method Exit on Logger that calls `os.Exit` or alternate exit function.
This keeps backward compatibility for static declaration of logger
that does not specify `ExitFunc` field.
2018-10-10 21:54:15 +08:00
Albert Salim 2be620216a Add option to panic in `test.NewNullLogger` to allow testing of
calls to `Fatal*`

See #813
2018-10-06 18:08:19 +08:00
Aaron.L.Xu 169c157a10 fix dead url for alt_exit.go 2017-02-08 19:18:14 +08:00
Aaron Greenlee a283a10442 Improved documentation of Fatal Handlers 2016-07-15 22:56:31 -04:00
Aaron Greenlee ff52e76f67 Go fmt alt exit addition 2016-06-24 10:24:56 -04:00
Aaron Greenlee a7755c5c03 Enhanced fatal calls so exit handlers can be invoked
While GO offers the ability to recover from panic there is no way to intercept an os.Exit event. To allow graceful shutdown and clean-up or programs which use Logrus to Fatal out I've borrowed ideas from the `atexit` package and enhanced Logrus.

Usage:
* When setting up the logger one call `RegisterExitHandler( func() {...} )` to add a handler that will be invoked for any `Fatal` call to the logger.
2016-06-24 10:23:56 -04:00