Update dlog
This commit is contained in:
parent
6e1eaf7b90
commit
fd9291b240
|
@ -65,10 +65,10 @@
|
||||||
revision = "0a025b7e63adc15a622f29b0b2c4c3848243bbf6"
|
revision = "0a025b7e63adc15a622f29b0b2c4c3848243bbf6"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
name = "github.com/jedisct1/dlog"
|
name = "github.com/jedisct1/dlog"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "b9f8973c5e799516c1f20a25c2da985a4e86bf0a"
|
revision = "b4b1aa34ca8400126287cfab55c7931e8f37f7de"
|
||||||
|
version = "0.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
|
@ -185,17 +185,15 @@ func logf(severity Severity, format string, args ...interface{}) {
|
||||||
defer _globals.Unlock()
|
defer _globals.Unlock()
|
||||||
if *_globals.useSyslog && _globals.systemLogger == nil {
|
if *_globals.useSyslog && _globals.systemLogger == nil {
|
||||||
systemLogger, err := newSystemLogger(_globals.appName, _globals.syslogFacility)
|
systemLogger, err := newSystemLogger(_globals.appName, _globals.syslogFacility)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
panic(err)
|
_globals.systemLogger = systemLogger
|
||||||
}
|
}
|
||||||
_globals.systemLogger = systemLogger
|
|
||||||
}
|
}
|
||||||
if _globals.fileName != nil && len(*_globals.fileName) > 0 && _globals.outFd == nil {
|
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)
|
outFd, err := os.OpenFile(*_globals.fileName, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
panic(err)
|
_globals.outFd = outFd
|
||||||
}
|
}
|
||||||
_globals.outFd = outFd
|
|
||||||
}
|
}
|
||||||
if _globals.systemLogger != nil {
|
if _globals.systemLogger != nil {
|
||||||
(*_globals.systemLogger).writeString(severity, message)
|
(*_globals.systemLogger).writeString(severity, message)
|
||||||
|
|
|
@ -7,11 +7,9 @@ type systemLogger struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSystemLogger(appName string, facility string) (*systemLogger, error) {
|
func newSystemLogger(appName string, facility string) (*systemLogger, error) {
|
||||||
err := eventlog.InstallAsEventCreate(appName, eventlog.Error|eventlog.Warning|eventlog.Info)
|
eventlog.InstallAsEventCreate(appName, eventlog.Error|eventlog.Warning|eventlog.Info)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var eventLogger *eventlog.Log
|
var eventLogger *eventlog.Log
|
||||||
|
var err error
|
||||||
if eventLogger, err = eventlog.Open(appName); err != nil {
|
if eventLogger, err = eventlog.Open(appName); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue