llog

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2013 License: BSD-3-Clause Imports: 3 Imported by: 1

README

llog

Very simple and straightforward implementation of leveled logs for Go(lang)

Build Status

Documentation: http://godoc.org/github.com/divoxx/llog

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

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.

const (
	DEBUG Level = iota
	INFO
	WARNING
	ERROR
)

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

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

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

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

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

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

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

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

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

func (l *Log) SetLevel(lvl Level)

SetLevel changes the logging level for the log instance.

func (*Log) Warning

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL