log

package
v0.2.1-0...-d3ae3b1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLevel is the default lowest unsuppressed severity.
	DefaultLevel = LevelInfo
)

Variables

View Source
var LevelNames = map[Level]string{
	LevelDebug: "debug",
	LevelInfo:  "info",
	LevelWarn:  "warn",
	LevelError: "error",
}

LevelNames maps severity levels to names.

View Source
var NamedLevels = map[string]Level{
	"debug":   LevelDebug,
	"info":    LevelInfo,
	"warn":    LevelWarn,
	"warning": LevelWarn,
	"error":   LevelError,
}

NamedLevels maps severity names to levels.

Functions

func Block

func Block(fn func(string, ...interface{}), prefix string, format string, args ...interface{})

Block emits a block of messages with the given emitting/printing function.

func Debug

func Debug(format string, args ...interface{})

Debug emit a debug message with the default source.

func DebugBlock

func DebugBlock(prefix string, format string, args ...interface{})

DebugBlock emits a block of debug messages with the default source.

func DebugEnabled

func DebugEnabled() bool

DebugEnabled returns the debugging state of the default source.

func EnableDebug

func EnableDebug(enable bool) bool

EnableDebug controls debugging for the default source.

func Error

func Error(format string, args ...interface{})

Error emit an error message with the default source.

func ErrorBlock

func ErrorBlock(prefix string, format string, args ...interface{})

ErrorBlock emits a block of error messages with the default source.

func Fatal

func Fatal(format string, args ...interface{})

Fatal emit a fatal error message with the default source.

func Info

func Info(format string, args ...interface{})

Info emit an info message with the default soruce.

func InfoBlock

func InfoBlock(prefix string, format string, args ...interface{})

InfoBlock emits a block of info messages with the default source.

func Panic

func Panic(format string, args ...interface{})

Panic emit a fatal error message with the default source and panic.

func RegisterBackend

func RegisterBackend(b Backend)

RegisterBackend registers a logger backend.

func Warn

func Warn(format string, args ...interface{})

Warn emit a warning message with the default source.

func WarnBlock

func WarnBlock(prefix string, format string, args ...interface{})

WarnBlock emits a block of warning messages with the default source.

Types

type Backend

type Backend interface {
	Name() string
	PrefixPreference() bool
	Enabled(Level) bool
	Info(message string)
	Warn(message string)
	Error(message string)

	Debug(message string)
}

Backend is an entity that can emit log messages.

type Level

type Level int32

Level is the log message severity level below which we suppress messages.

const (
	// LevelDebug corresponds to debug messages.
	LevelDebug Level = iota
	// LevelInfo corresponds to informational messages.
	LevelInfo
	// LevelWarn corresponds to warning messages.
	LevelWarn
	// LevelError corresponds to error messages.
	LevelError
)

func (*Level) Set

func (l *Level) Set(value string) error

Set is the flag.Value setter for Level.

func (Level) String

func (l Level) String() string

String is the flag.Value stringification for Level.

type Logger

type Logger interface {
	Info(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Error(format string, args ...interface{})
	Fatal(format string, args ...interface{})
	Panic(format string, args ...interface{})

	EnableDebug(bool) bool
	DebugEnabled() bool
	Debug(format string, args ...interface{})
	Block(fn func(string, ...interface{}), prefix string, format string, args ...interface{})
	DebugBlock(prefix string, format string, args ...interface{})
	InfoBlock(prefix string, format string, args ...interface{})
	WarnBlock(prefix string, format string, args ...interface{})
	ErrorBlock(prefix string, format string, args ...interface{})

	Stop()
}

Logger is the interface for configuring and producing log messages.

func Default

func Default() Logger

Default gets the default logger.

func Get

func Get(source string) Logger

Get an existing logger or create a new one.

func NewLogger

func NewLogger(source string) Logger

NewLogger creates a new logger, getting the existing one if possible.

Jump to

Keyboard shortcuts

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