logging

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: MIT Imports: 9 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = &Options{
	Backend: "simple",
}

DefaultOptions common default options

Functions

func RegisterBackend

func RegisterBackend(name string, factory backendFactory)

Types

type Level

type Level int

Level is an enumeration type of the supported loging levels

const (
	// Fatal level, is the highest logging level for fatal errors (e.g. panics)
	Fatal Level = iota
	// Error level
	Error
	// Warn level
	Warn
	// Info level
	Info
	// Debug level
	Debug
)

type Logger

type Logger interface {
	// ErrorErr simply logs an error (inclduing stack if created vis pkg/errors)
	ErrorErr(error)
	// Errorf logs a formated error message
	Errorf(format string, args ...interface{})
	// Error logs an error message
	Error(args ...interface{})
	// Warnf logs a formatted warning message
	Warnf(format string, args ...interface{})
	// Warn logs a warning message
	Warn(args ...interface{})
	// Infof logs a formatted info message
	Infof(format string, args ...interface{})
	// Info logs an info message
	Info(args ...interface{})
	// Debugf logs a formatted debug message
	Debugf(format string, args ...interface{})
	// Debug logs a debug message
	Debug(args ...interface{})

	// Create a child logger with fields (this field will be added to the fields
	// of the current logger)
	WithContext(fields map[string]interface{}) Logger
	// Create a child logger with an additional field
	WithField(name, value string) Logger
}

Logger is a generic logger interface to the different logger implementations

func NewLogger

func NewLogger(options Options) Logger

NewLogger configure a Logger implementation

func NewSimpleLogger

func NewSimpleLogger(options Options) Logger

NewSimpleLogger creates a simple Logger based on the golang log package

func NewSimpleLoggerNull

func NewSimpleLoggerNull(options Options) Logger

NewSimpleLoggerNull create a simple Logger discarding all log entries (i.e. /dev/null). Useful for testing where you do not want to polute testing output with log messages.

type Options

type Options struct {
	Backend   string
	LogFile   string
	LogFormat string
	Level     Level
	Output    io.Writer
}

Options required to configure a Logger implementation

func (Options) GetOutput

func (o Options) GetOutput() io.Writer

GetOutput gets the output where the log is written to

type SimpleStackTracer

type SimpleStackTracer interface {
	ErrorStack() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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