diff --git a/logging/consts_windows.go b/logging/consts_windows.go index e674112..2c29a9e 100644 --- a/logging/consts_windows.go +++ b/logging/consts_windows.go @@ -4,12 +4,14 @@ import ( `os` `path/filepath` `regexp` + + `r00t2.io/goutils/bitmask` ) // Flags for logger configuration. These are used internally. const ( // LogUndefined indicates an undefined Logger type. - LogUndefined types.MaskBit = 1 << iota + LogUndefined bitmask.MaskBit = 1 << iota // LogWinLogger indicates a WinLogger Logger type (Event Log). LogWinLogger // LogFile flags a FileLogger Logger type. diff --git a/logging/funcs_multilogger_mgr_windows.go b/logging/funcs_multilogger_mgr_windows.go index 7d00972..7e42c27 100644 --- a/logging/funcs_multilogger_mgr_windows.go +++ b/logging/funcs_multilogger_mgr_windows.go @@ -1,5 +1,9 @@ package logging +import ( + `github.com/google/uuid` +) + /* AddDefaultLogger adds a default Logger (as would be determined by GetLogger) to a MultiLogger. @@ -15,7 +19,7 @@ package logging Only the first logPaths entry that "works" will be used, later entries will be ignored. Currently this will almost always return a WinLogger. */ -func (m *MultiLogger) AddDefaultLogger(identifier string, eventIDs *WinEventID) (err error) { +func (m *MultiLogger) AddDefaultLogger(identifier string, eventIDs *WinEventID, logPaths ...string) (err error) { var l Logger var exists bool @@ -29,7 +33,12 @@ func (m *MultiLogger) AddDefaultLogger(identifier string, eventIDs *WinEventID) return } - if l, err = GetLogger(m.EnableDebug, m.Prefix, eventIDs, logPaths...); err != nil { + if logPaths != nil { + l, err = GetLogger(m.EnableDebug, m.Prefix, eventIDs, logPaths...); + } else { + l, err = GetLogger(m.EnableDebug, m.Prefix, eventIDs); + } + if err != nil { return } diff --git a/logging/funcs_windows.go b/logging/funcs_windows.go index 47ff61c..14a43cf 100644 --- a/logging/funcs_windows.go +++ b/logging/funcs_windows.go @@ -2,7 +2,11 @@ package logging import ( `errors` + `path` `strings` + + `r00t2.io/goutils/bitmask` + `r00t2.io/sysutils/paths` ) /* diff --git a/logging/funcs_winlogger_windows.go b/logging/funcs_winlogger_windows.go index f7317d2..79ce40f 100644 --- a/logging/funcs_winlogger_windows.go +++ b/logging/funcs_winlogger_windows.go @@ -2,6 +2,7 @@ package logging import ( `errors` + `fmt` `golang.org/x/sys/windows/svc/eventlog` ) @@ -25,7 +26,7 @@ func (l *WinLogger) Setup() { l.eids.Notice, l.eids.Warning, } { - if !(1 <= eid <= 1000) { + if !((eid <= 1000) && (1 <= eid)) { err = errors.New("event IDs must be between 1 and 1000 inclusive") panic(err) } @@ -197,7 +198,7 @@ func (l *WinLogger) Err(s string, v ...interface{}) (err error) { msg = s } - err = l.elog.Error(l.eids.Error, msg) + err = l.elog.Error(l.eids.Err, msg) return