Documentation
¶
Overview ¶
The package logger provides a Logger type that can receive log records. Logger will only display a record if it is as severe as or more severe than the loglevel set for the Logger. Users of Logger therefore can control how much logging output they will see while running their program. A Logger can be used by multiple goroutines.
For usable loglevels see CONSTANTS.
Index ¶
- Constants
- type LevelFlag
- type Logger
- func (l *Logger) Alert(v ...interface{}) (n int, err error)
- func (l *Logger) Critical(v ...interface{}) (n int, err error)
- func (l *Logger) Debug(v ...interface{}) (n int, err error)
- func (l *Logger) Error(v ...interface{}) (n int, err error)
- func (l *Logger) Info(v ...interface{}) (n int, err error)
- func (l *Logger) Level() int
- func (l *Logger) LevelStr() string
- func (l *Logger) Notice(v ...interface{}) (n int, err error)
- func (l *Logger) Panic(v ...interface{}) (n int, err error)
- func (l *Logger) Println(level int, v ...interface{}) (n int, err error)
- func (l *Logger) SetLevel(level int)
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) SetTimeFormat(format string)
- func (l *Logger) TimeFormat() string
- func (l *Logger) Warning(v ...interface{}) (n int, err error)
Constants ¶
const ( Level_Panic = iota Level_Alert Level_Critical Level_Error Level_Warning Level_Notice Level_Info Level_Debug )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the data type used for sending log records to.
func New ¶
New constructs a new Logger. It will print a log record to its given writer if it fulfills the Logger's designated loglevel or a more severe one. If you set the level to Level_Critical, the Logger will print all messages of Level_Panic or Level_Alert or Level_Critical.
func (*Logger) LevelStr ¶
LevelStr returns the string representation of the Logger's current loglevel.
func (*Logger) Panic ¶
Panic sends a message of loglevel Level_Panic to the Logger. Please note that it does NOT call panic()!
func (*Logger) Println ¶
Println writes the log message if its log level is equally severe or more severe than that set for the Logger.
func (*Logger) SetLevel ¶
SetLevel sets a new loglevel for the Logger. Setting an invalid loglevel will cause a panic.
func (*Logger) SetTimeFormat ¶
SetTimeFormat takes a format string as defined in the "(t Time) Format" function of go's "time" module. If such a string is set, log records will display a timestamp formatted like specified by the format string. To remove timestamps from future log records, set the format string to "".
func (*Logger) TimeFormat ¶
TimeFormat returns the current format string for the timestamp. If it returns "", log records will have no timestamp.