mirror of
https://github.com/rancher/os.git
synced 2025-09-01 23:04:41 +00:00
try to simplify logging
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
33
log/log.go
33
log/log.go
@@ -109,29 +109,32 @@ func InitLogger() {
|
||||
}
|
||||
thisLog := logrus.New()
|
||||
|
||||
filename := "/dev/kmsg"
|
||||
f, err := os.OpenFile(filename, os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
logrus.Debugf("error opening /dev/kmsg %s", err)
|
||||
}
|
||||
|
||||
// Filter what the user sees (info level, unless they set --debug)
|
||||
stdLogger := logrus.StandardLogger()
|
||||
showuserHook, err := NewShowuserlogHook(stdLogger.Level)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
logrus.Errorf("hook failure %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
// We're all set up, now we can make it global
|
||||
appLog = thisLog
|
||||
userHook = showuserHook
|
||||
// TODO: look into containerized syslog
|
||||
//filename := "/dev/kmsg"
|
||||
filename := "/var/log/log"
|
||||
f, err := os.OpenFile(filename, os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
logrus.Debugf("error opening %s: %s", filename, err)
|
||||
} else {
|
||||
// We're all set up, now we can make it global
|
||||
appLog = thisLog
|
||||
userHook = showuserHook
|
||||
|
||||
thisLog.Hooks.Add(showuserHook)
|
||||
logrus.StandardLogger().Hooks.Add(showuserHook)
|
||||
thisLog.Out = f
|
||||
logrus.SetOutput(f)
|
||||
thisLog.Level = logrus.DebugLevel
|
||||
thisLog.Hooks.Add(showuserHook)
|
||||
logrus.StandardLogger().Hooks.Add(showuserHook)
|
||||
|
||||
thisLog.Out = f
|
||||
logrus.SetOutput(f)
|
||||
thisLog.Level = logrus.DebugLevel
|
||||
}
|
||||
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user