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

4
Gopkg.lock generated
View File

@ -65,10 +65,10 @@
revision = "0a025b7e63adc15a622f29b0b2c4c3848243bbf6"
[[projects]]
branch = "master"
name = "github.com/jedisct1/dlog"
packages = ["."]
revision = "b9f8973c5e799516c1f20a25c2da985a4e86bf0a"
revision = "b4b1aa34ca8400126287cfab55c7931e8f37f7de"
version = "0.1"
[[projects]]
branch = "master"

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
}