Documentation ¶
Overview ¶
The package defines a type MyLogger, with methods for formatting output, same as the log package, and it also has a predefined 'standard' logger with associated logging functions that can be used without creating a custom logger. This standard logger has a predefined loglevel of Notice which means that any logs created by Info or Debug functions will be discarded.
Index ¶
- Constants
- Variables
- func Critical(v ...interface{})
- func Criticalf(format string, v ...interface{})
- func Criticalln(v ...interface{})
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Debugln(v ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Errorln(v ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Infoln(v ...interface{})
- func Notice(v ...interface{})
- func Noticef(format string, v ...interface{})
- func Noticeln(v ...interface{})
- func Set(name, displayname string, level, flags int, output io.Writer, ...)
- func SetErrOutput(w io.Writer)
- func SetFlags(flag int)
- func SetLogLevel(level int)
- func SetOutput(w io.Writer)
- func Warning(v ...interface{})
- func Warningf(format string, v ...interface{})
- func Warningln(v ...interface{})
- type MyLogger
- func (ml *MyLogger) Critical(v ...interface{})
- func (ml *MyLogger) Criticalf(format string, v ...interface{})
- func (ml *MyLogger) Criticalln(v ...interface{})
- func (ml *MyLogger) Debug(v ...interface{})
- func (ml *MyLogger) Debugf(format string, v ...interface{})
- func (ml *MyLogger) Debugln(v ...interface{})
- func (ml *MyLogger) Error(v ...interface{})
- func (ml *MyLogger) Errorf(format string, v ...interface{})
- func (ml *MyLogger) Errorln(v ...interface{})
- func (ml *MyLogger) Info(v ...interface{})
- func (ml *MyLogger) Infof(format string, v ...interface{})
- func (ml *MyLogger) Infoln(v ...interface{})
- func (ml *MyLogger) Notice(v ...interface{})
- func (ml *MyLogger) Noticef(format string, v ...interface{})
- func (ml *MyLogger) Noticeln(v ...interface{})
- func (ml *MyLogger) SetDisplayName(name string)
- func (ml *MyLogger) SetErrOutput(w io.Writer)
- func (ml *MyLogger) SetFlags(flag int)
- func (ml *MyLogger) SetLogLevel(level int)
- func (ml *MyLogger) SetOutput(w io.Writer)
- func (ml *MyLogger) Warning(v ...interface{})
- func (ml *MyLogger) Warningf(format string, v ...interface{})
- func (ml *MyLogger) Warningln(v ...interface{})
Constants ¶
const ( LevelNone = iota LevelCritical LevelError LevelWarning LevelNotice LevelInfo LevelDebug )
These flags define the available log levels that can be configured. A level of LevelWarning means that only messages of level including and above will be displayed (Warning, Error, Critical). So to display log messages of level Debug, the log level must be set to LevelDebug.
const ( Ldate = 1 << iota Ltime Lmicroseconds Llongfile Lshortfile LUTC Lmsgprefix LstdFlags = Ldate | Ltime )
These flags define which test to prefix each log entry generated by the logger and are copied from the default log package.
Variables ¶
These flags define helper values for logging output
Functions ¶
func Criticalln ¶
func Criticalln(v ...interface{})
func Set ¶ added in v0.2.0
Setup a new logger for a given reference. Intended usage is to specify a custom logger for a packet.
func SetErrOutput ¶ added in v0.3.2
func SetLogLevel ¶
func SetLogLevel(level int)
Types ¶
type MyLogger ¶
type MyLogger struct {
// contains filtered or unexported fields
}
A MyLogger represents an active logging object that serves as a wrapper around the Logger from the log package. Each logging operation will check against the defined loglevel to see if the message should be logged before passing it on to the underlying log packets Logger.
func New ¶
New creates a new MyLogger. The level variable sets the loglevel which should be used to filter what is logged. The flags variable is passed directly to the underlying log package to set Logger flags. The output variable sets the destination to which log data will be written.
func (*MyLogger) Criticalln ¶
func (ml *MyLogger) Criticalln(v ...interface{})