mirror of
https://github.com/rancher/os.git
synced 2025-09-21 02:19:48 +00:00
Add defered syslog hook
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
24
log/log.go
24
log/log.go
@@ -4,6 +4,8 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -110,7 +112,15 @@ func WithFields(fields Fields) *logrus.Entry {
|
||||
return appLog.WithFields(logrus.Fields(fields))
|
||||
}
|
||||
|
||||
// InitLogger sets up Logging to log to /dev/kmsg and to Syslog
|
||||
func InitLogger() {
|
||||
InitDeferedLogger()
|
||||
SyslogReady(false)
|
||||
}
|
||||
|
||||
// InitDeferedLogger sets up logging to /dev/kmsg and to an internal buffer
|
||||
// which is then written to Syslog when signaled by SyslogReady()
|
||||
func InitDeferedLogger() {
|
||||
if userHook != nil {
|
||||
return // we've already initialised it
|
||||
}
|
||||
@@ -148,3 +158,17 @@ func InitLogger() {
|
||||
|
||||
thisLog.Debugf("START: %v in %s", os.Args, pwd)
|
||||
}
|
||||
|
||||
// SyslogReady tells the storeing User hook to start writing to syslog
|
||||
func SyslogReady(logHook bool) error {
|
||||
if userHook != nil {
|
||||
if logHook {
|
||||
logrus.Infof("Starting Syslog Hook")
|
||||
fmt.Fprintf(appLog.Out, "------------ Starting defered Syslog Hook (%s) ----------------\n", os.Args[0])
|
||||
} else {
|
||||
fmt.Fprintf(appLog.Out, "------------ Starting Syslog Hook (%s) ----------------\n", os.Args[0])
|
||||
}
|
||||
return userHook.LogSystemReady()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user