From 4346c76f26ec031258a1d8f5f08cfb829f74611e Mon Sep 17 00:00:00 2001 From: Albert Salim Date: Wed, 10 Oct 2018 21:57:58 +0800 Subject: [PATCH] Remove unnecessary wrapper function on `os.Exit` --- alt_exit.go | 6 ------ logger.go | 6 ++++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/alt_exit.go b/alt_exit.go index 183db77..8af9063 100644 --- a/alt_exit.go +++ b/alt_exit.go @@ -48,12 +48,6 @@ func runHandlers() { // 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) } diff --git a/logger.go b/logger.go index 364819e..21f49ec 100644 --- a/logger.go +++ b/logger.go @@ -36,6 +36,8 @@ type Logger struct { ExitFunc exitFunc } +type exitFunc func(int) + type MutexWrap struct { lock sync.Mutex disabled bool @@ -75,7 +77,7 @@ func New() *Logger { Formatter: new(TextFormatter), Hooks: make(LevelHooks), Level: InfoLevel, - ExitFunc: osExit, + ExitFunc: os.Exit, } } @@ -316,7 +318,7 @@ func (logger *Logger) Panicln(args ...interface{}) { func (logger *Logger) Exit(code int) { runHandlers() if logger.ExitFunc == nil { - logger.ExitFunc = osExit + logger.ExitFunc = os.Exit } logger.ExitFunc(code) }