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.
This commit is contained in:
Albert Salim
2018-10-10 21:54:15 +08:00
parent 2be620216a
commit 99bc300c8d
5 changed files with 26 additions and 25 deletions
+6 -2
View File
@@ -45,11 +45,15 @@ func runHandlers() {
}
}
type exitFunc func(int)
// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
func Exit(code int) {
runHandlers()
osExit(code)
}
type exitFunc func(int)
func osExit(code int) {
os.Exit(code)
}