logger

package
v0.14.48 Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: MPL-2.0, MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logger implements a standardized logger with callback functionality

Index

Constants

Variables

View Source
var DefaultLogger = New()

DefaultLogger logs to standard output with a time prefix.

Functions

This section is empty.

Types

type Line

type Line struct {
	When    time.Time `json:"when"`
	Message string    `json:"message"`
	Level   LogLevel  `json:"level"`
}

A Line represents a single log entry.

type LogLevel

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

type Logger

type Logger interface {
	AddHandler(level LogLevel, h MessageHandler)
	SetFlags(flag int)
	SetPrefix(prefix string)
	Debugln(vals ...interface{})
	Debugf(format string, vals ...interface{})
	Verboseln(vals ...interface{})
	Verbosef(format string, vals ...interface{})
	Infoln(vals ...interface{})
	Infof(format string, vals ...interface{})
	Warnln(vals ...interface{})
	Warnf(format string, vals ...interface{})
	Fatalln(vals ...interface{})
	Fatalf(format string, vals ...interface{})
	ShouldDebug(facility string) bool
	SetDebug(facility string, enabled bool)
	Facilities() map[string]string
	FacilityDebugging() []string
	NewFacility(facility, description string) Logger
}

func New

func New() Logger

type MessageHandler

type MessageHandler func(l LogLevel, msg string)

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

type Recorder

type Recorder interface {
	Since(t time.Time) []Line
	Clear()
}

A Recorder keeps a size limited record of log events.

func NewRecorder

func NewRecorder(l Logger, level LogLevel, size, initial int) Recorder

Jump to

Keyboard shortcuts

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