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:
+6
-2
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user