llog: github.com/divoxx/llog Index | Files

package llog

import "github.com/divoxx/llog"

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

Package Files

llog.go

type Level Uses

type Level uint8

Level represents log levels which are sorted based on the underlying number associated to it.

const (
    DEBUG Level = iota
    INFO
    WARNING
    ERROR
)

Definitions of available levels: Debug < Info < Warning < Error.

type Log Uses

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 Uses

func New(w io.Writer, l Level) *Log

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) Debug Uses

func (l *Log) Debug(msg ...interface{}) error

Debug writes to the Log only if the log's level is set to Debug.

func (*Log) Debugf Uses

func (l *Log) Debugf(fmtStr string, msg ...interface{}) error

Debugf writes a message formatted (as fmt.Printf) to the Log only if the log's level is set to Debug.

func (*Log) Error Uses

func (l *Log) Error(msg ...interface{}) error

Error writes to the Log only if the log's level is set to Error.

func (*Log) Errorf Uses

func (l *Log) Errorf(fmtStr string, msg ...interface{}) error

Errorf writes a message formatted (as fmt.Printf) to the Log only if the log's level is set to Error.

func (*Log) Info Uses

func (l *Log) Info(msg ...interface{}) error

Info writes to the Log only if the log's level is set to Info.

func (*Log) Infof Uses

func (l *Log) Infof(fmtStr string, msg ...interface{}) error

Infof writes a message formatted (as fmt.Printf) to the Log only if the log's level is set to Info.

func (*Log) SetLevel Uses

func (l *Log) SetLevel(lvl Level)

SetLevel changes the logging level for the log instance.

func (*Log) Warning Uses

func (l *Log) Warning(msg ...interface{}) error

Warning writes to the Log only if the log's level is set to Warning.

func (*Log) Warningf Uses

func (l *Log) Warningf(fmtStr string, msg ...interface{}) error

Warningf writes a message formatted (as fmt.Printf) to the Log only if the log's level is set to Warning.

Package llog imports 3 packages (graph) and is imported by 2 packages. Updated 2016-07-20. Refresh now. Tools for package owners.