Update dlog

This commit is contained in:
Frank Denis 2018-01-19 20:27:48 +01:00
parent 6e1eaf7b90
commit fd9291b240
3 changed files with 8 additions and 12 deletions

View file

@ -185,17 +185,15 @@ func logf(severity Severity, format string, args ...interface{}) {
defer _globals.Unlock()
if *_globals.useSyslog && _globals.systemLogger == nil {
systemLogger, err := newSystemLogger(_globals.appName, _globals.syslogFacility)
if err != nil {
panic(err)
if err == nil {
_globals.systemLogger = systemLogger
}
_globals.systemLogger = systemLogger
}
if _globals.fileName != nil && len(*_globals.fileName) > 0 && _globals.outFd == nil {
outFd, err := os.OpenFile(*_globals.fileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
if err != nil {
panic(err)
if err == nil {
_globals.outFd = outFd
}
_globals.outFd = outFd
}
if _globals.systemLogger != nil {
(*_globals.systemLogger).writeString(severity, message)

View file

@ -7,11 +7,9 @@ type systemLogger struct {
}
func newSystemLogger(appName string, facility string) (*systemLogger, error) {
err := eventlog.InstallAsEventCreate(appName, eventlog.Error|eventlog.Warning|eventlog.Info)
if err != nil {
return nil, err
}
eventlog.InstallAsEventCreate(appName, eventlog.Error|eventlog.Warning|eventlog.Info)
var eventLogger *eventlog.Log
var err error
if eventLogger, err = eventlog.Open(appName); err != nil {
return nil, err
}