Documentation ¶
Overview ¶
llog is a simple and straightforward implementation of leveled logs for go.
The levels are defined as follow: Debug < Info < Warning < Error.
A call to any of the logging methods will only append to the log if the level represented by the method is higher or equal to the level set in the Log instance.
For example: a Log w/ level Warning will only append to the log any call to Error, Errorf, Warning and Warningf. All other calls will be ignored.
l := llog.New(os.Stdout, llog.WARNING) l.Warning("Something wrong occurred") // Gets logged l.Info("You might like to know this") // Doesn't get logged
Index ¶
- type Level
- type Log
- func (l *Log) Debug(msg ...interface{}) error
- func (l *Log) Debugf(fmtStr string, msg ...interface{}) error
- func (l *Log) Error(msg ...interface{}) error
- func (l *Log) Errorf(fmtStr string, msg ...interface{}) error
- func (l *Log) Info(msg ...interface{}) error
- func (l *Log) Infof(fmtStr string, msg ...interface{}) error
- func (l *Log) SetLevel(lvl Level)
- func (l *Log) Warning(msg ...interface{}) error
- func (l *Log) Warningf(fmtStr string, msg ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Level ¶
type Level uint8
Level represents log levels which are sorted based on the underlying number associated to it.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is an instance that contains a reference to an io.Writer and a level set. For more info, check New documentation.
func New ¶
New creates a new instance of Log that will log to the provided io.Writer only if the method used for logging is enabled for the provided level. See package documentation for more details and examples.
func (*Log) Debugf ¶
Debugf writes a message formatted (as fmt.Printf) to the Log only if the log's level is set to Debug.
func (*Log) Errorf ¶
Errorf writes a message formatted (as fmt.Printf) to the Log only if the log's level is set to Error.
func (*Log) Infof ¶
Infof writes a message formatted (as fmt.Printf) to the Log only if the log's level is set to Info.