Documentation ¶
Overview ¶
Provides an io.Writer that filters log messages based on a log level.
Valid log levels are: DEBUG, INFO, WARN, ERROR.
Log messages need to begin with a L! where L is one of D, I, W, or E.
Examples:
log.Println("D! this is a debug log") log.Println("I! this is an info log") log.Println("W! this is a warn log") log.Println("E! this is an error log")
Simply pass a instance of wlog.Writer to log.New or use the helper wlog.New function.
The log level can be changed via the SetLevel or the SetLevelFromName functions.
Index ¶
Constants ¶
View Source
const Delimiter = '!'
Variables ¶
View Source
var ReverseLevels map[Level]byte
View Source
var StringToLevel = map[string]Level{ "DEBUG": DEBUG, "INFO": INFO, "WARN": WARN, "ERROR": ERROR, "OFF": OFF, }
name to Level mappings
Functions ¶
func SetLevelFromName ¶
Set the log level via a string name. To set it directly use 'logLevel'.
Types ¶
type StaticLevelWriter ¶
type StaticLevelWriter struct {
// contains filtered or unexported fields
}
StaticLevelWriter prefixes all log messages with a static log level.
func NewStaticLevelWriter ¶
func NewStaticLevelWriter(w io.Writer, level Level) *StaticLevelWriter
Create a writer that always append a static log prefix to all messages. Usefult for supplying a *log.Logger to a package that doesn't prefix log messages itself.
Click to show internal directories.
Click to hide internal directories.