Improved documentation of Fatal Handlers

This commit is contained in:
Aaron Greenlee
2016-07-15 22:56:31 -04:00
parent 1d4b5462f8
commit a283a10442
2 changed files with 22 additions and 1 deletions
+6 -1
View File
@@ -51,9 +51,14 @@ func Exit(code int) {
os.Exit(code)
}
// RegisterExitHandler adds a Logrus atexit handler, call logrus.Exit to invoke
// RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke
// all handlers. The handlers will also be invoked when any Fatal log entry is
// made.
//
// This method is useful when a caller wishes to use logrus to log a fatal
// message but also needs to gracefully shutdown. An example usecase could be
// closing database connections, or sending a alert that the application is
// closing.
func RegisterExitHandler(handler func()) {
handlers = append(handlers, handler)
}