finalizing logging and multierror
This commit is contained in:
@@ -5,30 +5,60 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
/*
|
||||
Logger is one of the various loggers offered by this module.
|
||||
*/
|
||||
type Logger interface {
|
||||
Alert(string, ...interface{}) error
|
||||
Crit(string, ...interface{}) error
|
||||
Debug(string, ...interface{}) error
|
||||
Emerg(string, ...interface{}) error
|
||||
Err(string, ...interface{}) error
|
||||
Info(string, ...interface{}) error
|
||||
Notice(string, ...interface{}) error
|
||||
Warning(string, ...interface{}) error
|
||||
DoDebug(bool)
|
||||
SetPrefix(string)
|
||||
GetPrefix() string
|
||||
Alert(s string, v ...interface{}) (err error)
|
||||
Crit(s string, v ...interface{}) (err error)
|
||||
Debug(s string, v ...interface{}) (err error)
|
||||
Emerg(s string, v ...interface{}) (err error)
|
||||
Err(s string, v ...interface{}) (err error)
|
||||
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()
|
||||
}
|
||||
|
||||
// StdLogger uses the log package in stdlib to perform all logging.
|
||||
type StdLogger struct {
|
||||
// All log.Logger fields/methods are exposed.
|
||||
*log.Logger
|
||||
/*
|
||||
EnableDebug indicates if the debug filter should be disabled (true) or if the filter should be enabled (false).
|
||||
This prevents potential data leak of sensitive information, as some loggers (e.g. FileLogger) will otherwise write all messages.
|
||||
*/
|
||||
EnableDebug bool
|
||||
Prefix string
|
||||
// Prefix indicates the prefix for log entries; in shared logs, this helps differentiate the source.
|
||||
Prefix string
|
||||
}
|
||||
|
||||
// FileLogger uses a StdLogger with a file handle writer to write to the file given at Path.
|
||||
type FileLogger struct {
|
||||
// StdLogger is used for the log formation and handling.
|
||||
StdLogger
|
||||
Path string
|
||||
// Path is the path to the logfile.
|
||||
Path string
|
||||
// writer is used for the writing out of the log file.
|
||||
writer *os.File
|
||||
}
|
||||
|
||||
// MultiLogger is used to contain one or more Loggers and present them all as a single Logger.
|
||||
type MultiLogger struct {
|
||||
/*
|
||||
EnableDebug indicates if the debug filter should be disabled (true) or if the filter should be enabled (false).
|
||||
This prevents potential data leak of sensitive information, as some loggers (e.g. FileLogger) will otherwise write all messages.
|
||||
*/
|
||||
EnableDebug bool
|
||||
// Prefix indicates the prefix for log entries; in shared logs, this helps differentiate the source.
|
||||
Prefix string
|
||||
/*
|
||||
Loggers contains a map of map[logname]Logger. It can be used to set log-specific options, or replace a Logger
|
||||
with one of a different type or options.
|
||||
*/
|
||||
Loggers map[string]Logger
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user