mirror of https://github.com/sirupsen/logrus.git
Remove unnecessary wrapper function on `os.Exit`
This commit is contained in:
parent
99bc300c8d
commit
4346c76f26
|
@ -48,12 +48,6 @@ func runHandlers() {
|
||||||
// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
|
// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
|
||||||
func Exit(code int) {
|
func Exit(code int) {
|
||||||
runHandlers()
|
runHandlers()
|
||||||
osExit(code)
|
|
||||||
}
|
|
||||||
|
|
||||||
type exitFunc func(int)
|
|
||||||
|
|
||||||
func osExit(code int) {
|
|
||||||
os.Exit(code)
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,8 @@ type Logger struct {
|
||||||
ExitFunc exitFunc
|
ExitFunc exitFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type exitFunc func(int)
|
||||||
|
|
||||||
type MutexWrap struct {
|
type MutexWrap struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
disabled bool
|
disabled bool
|
||||||
|
@ -75,7 +77,7 @@ func New() *Logger {
|
||||||
Formatter: new(TextFormatter),
|
Formatter: new(TextFormatter),
|
||||||
Hooks: make(LevelHooks),
|
Hooks: make(LevelHooks),
|
||||||
Level: InfoLevel,
|
Level: InfoLevel,
|
||||||
ExitFunc: osExit,
|
ExitFunc: os.Exit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +318,7 @@ func (logger *Logger) Panicln(args ...interface{}) {
|
||||||
func (logger *Logger) Exit(code int) {
|
func (logger *Logger) Exit(code int) {
|
||||||
runHandlers()
|
runHandlers()
|
||||||
if logger.ExitFunc == nil {
|
if logger.ExitFunc == nil {
|
||||||
logger.ExitFunc = osExit
|
logger.ExitFunc = os.Exit
|
||||||
}
|
}
|
||||||
logger.ExitFunc(code)
|
logger.ExitFunc(code)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue