log

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Discard = &logger{
	Handler: dispatcher(func(log Entry) {}),
}

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Level   Level
	Message string
	Fields  []Field
	Path    string // File path can be empty
}

type Field

type Field struct {
	Key   string
	Value string // Can be empty, though usually a user error
}

type Fields

type Fields []Field

func (Fields) Len

func (f Fields) Len() int

func (Fields) Less

func (f Fields) Less(i, j int) bool

func (Fields) Swap

func (f Fields) Swap(i, j int)

type Flusher

type Flusher interface {
	Flush()
}

Flusher is an optional interface

type Handler

type Handler interface {
	Log(log Entry)
}

type Level

type Level uint8

Level of the logger

const (
	DebugLevel Level = iota + 1
	InfoLevel
	NoticeLevel
	WarnLevel
	ErrorLevel
)

Log level

func ParseLevel

func ParseLevel(level string) (Level, error)

func (*Level) Set

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

func (Level) String

func (level Level) String() string

type Logger

type Logger interface {
	Debug(message string, args ...interface{})
	Info(message string, args ...interface{})
	Notice(message string, args ...interface{})
	Warn(message string, args ...interface{})
	Error(message string, args ...interface{})
}

func New

func New(handler Handler, options ...Option) Logger

New logger

type Option

type Option func(logger *logger)

func WithPath

func WithPath(includePath bool) Option

WithPath determines whether or not to pass the file path to the handler This is typically turned off to improve performance, but is really handy for debugging.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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