cli: Refactor the logger setup
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/purpleidea/mgmt/util/errwrap"
|
||||
@@ -81,3 +83,16 @@ func SafeProgram(program string) string {
|
||||
//}
|
||||
return program
|
||||
}
|
||||
|
||||
// LogSetup changes some of the core logger package settings.
|
||||
func LogSetup(debug bool) {
|
||||
// TODO: Move these log package initialization steps to the top main.go?
|
||||
logFlags := log.LstdFlags
|
||||
if debug {
|
||||
logFlags = logFlags + log.Lshortfile
|
||||
}
|
||||
logFlags = logFlags - log.Ldate // remove the date for now
|
||||
log.SetFlags(logFlags)
|
||||
|
||||
log.SetOutput(os.Stderr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user