Windows Event Log, error output
Adding more Event Log support, and modifying the loggers so they return errors in their operational functions.
This commit is contained in:
@@ -17,11 +17,11 @@ type Logger interface {
|
||||
Info(s string, v ...interface{}) (err error)
|
||||
Notice(s string, v ...interface{}) (err error)
|
||||
Warning(s string, v ...interface{}) (err error)
|
||||
DoDebug(d bool)
|
||||
SetPrefix(p string)
|
||||
GetPrefix() (p string)
|
||||
Setup()
|
||||
Shutdown()
|
||||
DoDebug(d bool) (err error)
|
||||
SetPrefix(p string) (err error)
|
||||
GetPrefix() (p string, err error)
|
||||
Setup() (err error)
|
||||
Shutdown() (err error)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -38,20 +38,42 @@ type StdLogger struct {
|
||||
EnableDebug bool
|
||||
// Prefix indicates the prefix for log entries; in shared logs, this helps differentiate the source.
|
||||
Prefix string
|
||||
/*
|
||||
LogFlags control some of the formatting options presented as an OR'd value.
|
||||
See https://pkg.go.dev/log#pkg-constants for flag details.
|
||||
e.g.:
|
||||
*StdLogger.LogFlags = log.Ldate | log.Lmicroseconds | log.Llongfile | log.LUTC // a very detailed log output
|
||||
*StdLogger.LogFlags = log.Ldate | log.Ltime // the flags used by log.Default() (also available as simply log.LstdFlags)
|
||||
The default is 0; no flags (no output except prefix if non-empty and message).
|
||||
You will need to run *StdLogger.Shutdown and then *StdLogger.Setup again if you wish to change this.
|
||||
*/
|
||||
LogFlags int
|
||||
}
|
||||
|
||||
// FileLogger uses a StdLogger with a file handle writer to write to the file given at Path.
|
||||
/*
|
||||
FileLogger uses a StdLogger with a file handle writer to write to the file given at Path.
|
||||
|
||||
NOTE: If you wish to change the FileLogger.StdLogger.LogFlags, do *not* run FileLogger.StdLogger.Setup after doing so as this
|
||||
will instead create a logger detached from the file handler. Instead, be sure to call FileLogger.Setup.
|
||||
(Alternatively, run FileLogger.Shutdown and replace your logger with a new FileLogger.)
|
||||
*/
|
||||
type FileLogger struct {
|
||||
// StdLogger is used for the log formation and handling. See StdLogger for more details.
|
||||
StdLogger
|
||||
// Path is the path to the logfile.
|
||||
Path string
|
||||
/*
|
||||
EnableStdOut is true if the log will send to STDOUT as well as the file.
|
||||
EnableStdOut is true if the log will send to STDOUT as well as the file (and STDERR if FileLogger.EnableStdErr == true).
|
||||
If false (default), it will only (silently) write to the log file.
|
||||
You will need to run FileLogger.Shutdown and then FileLogger.Setup again if you wish to change this.
|
||||
*/
|
||||
EnableStdOut bool
|
||||
/*
|
||||
EnableStdErr is true if the log will send to STDERR as well as the file (and STDOUT if FileLogger.EnableStdOut == true).
|
||||
If false (default), it will only (silently) write to the log file.
|
||||
You will need to run *FileLogger.Shutdown and then *FileLogger.Setup again if you wish to change this.
|
||||
*/
|
||||
EnableStdOut bool
|
||||
EnableStdErr bool
|
||||
// writer is used for the writing out of the log file.
|
||||
writer *os.File
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user