logger

package
v0.11.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2015 License: MIT, MPL-2.0 Imports: 5 Imported by: 0

README

logger

A small wrapper around log to provide log levels.

Documentation

http://godoc.org/github.com/calmh/logger

License

MIT

Documentation

Overview

Package logger implements a standardized logger with callback functionality

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = New()

The default logger logs to standard output with a time prefix.

Functions

This section is empty.

Types

type LogLevel

type LogLevel int
const (
	LevelDebug LogLevel = iota
	LevelInfo
	LevelOK
	LevelWarn
	LevelFatal
	NumLevels
)

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func New

func New() *Logger

func (*Logger) AddHandler

func (l *Logger) AddHandler(level LogLevel, h MessageHandler)

AddHandler registers a new MessageHandler to receive messages with the specified log level or above.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, vals ...interface{})

Debugf logs a formatted line with a DEBUG prefix.

func (*Logger) Debugln

func (l *Logger) Debugln(vals ...interface{})

Debugln logs a line with a DEBUG prefix.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, vals ...interface{})

Fatalf logs a formatted line with a FATAL prefix and exits the process with exit code 1.

func (*Logger) Fatalln

func (l *Logger) Fatalln(vals ...interface{})

Fatalln logs a line with a FATAL prefix and exits the process with exit code 1.

func (*Logger) Infof

func (l *Logger) Infof(format string, vals ...interface{})

Infof logs a formatted line with an INFO prefix.

func (*Logger) Infoln

func (l *Logger) Infoln(vals ...interface{})

Infoln logs a line with an INFO prefix.

func (*Logger) Okf

func (l *Logger) Okf(format string, vals ...interface{})

Okf logs a formatted line with an OK prefix.

func (*Logger) Okln

func (l *Logger) Okln(vals ...interface{})

Okln logs a line with an OK prefix.

func (*Logger) SetFlags

func (l *Logger) SetFlags(flag int)

See log.SetFlags

func (*Logger) SetPrefix

func (l *Logger) SetPrefix(prefix string)

See log.SetPrefix

func (*Logger) Warnf

func (l *Logger) Warnf(format string, vals ...interface{})

Warnf logs a formatted line with a WARNING prefix.

func (*Logger) Warnln

func (l *Logger) Warnln(vals ...interface{})

Warnln logs a formatted line with a WARNING prefix.

type MessageHandler

type MessageHandler func(l LogLevel, msg string)

A MessageHandler is called with the log level and message text.

Jump to

Keyboard shortcuts

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