logger

package
v0.0.0-...-ba7efc3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BufPool = buffer.NewPool(_bufSize)

Functions

func FormatTime

func FormatTime(t time.Time) string

func LeftJustified

func LeftJustified(s string, v byte, size int) string

func RightJustified

func RightJustified(s string, v byte, size int) string

Types

type BuildLabelFunc

type BuildLabelFunc func(id, name string) string

type Level

type Level int
const (
	LevelTrace Level
	LevelDebug
	LevelInfo
	LevelNotice
	LevelWarning
	LevelError
	LevelFatal
)

func StringToLevel

func StringToLevel(level string) Level

func (Level) String

func (l Level) String() string

type Logger

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

func New

func New(id, name string, opts ...Option) *Logger

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Debug

func (l *Logger) Debug(msg string, kv ...any)

func (*Logger) Error

func (l *Logger) Error(err error, msg string, kv ...any)

func (*Logger) FIXME

func (l *Logger) FIXME(err error, msg string)

func (*Logger) Fatal

func (l *Logger) Fatal(err error, msg string, kv ...any)

func (*Logger) ID

func (l *Logger) ID() string

func (*Logger) Info

func (l *Logger) Info(msg string, kv ...any)

func (*Logger) Label

func (l *Logger) Label() string

func (*Logger) Level

func (l *Logger) Level() string

func (*Logger) Name

func (l *Logger) Name() string

func (*Logger) NewLogger

func (l *Logger) NewLogger(id, name string, opts ...Option) *Logger

func (*Logger) NewStdLogger

func (l *Logger) NewStdLogger(level, prefix string, flag int) *log.Logger

func (*Logger) Notice

func (l *Logger) Notice(msg string, kv ...any)

func (*Logger) Output

func (l *Logger) Output() Output

func (*Logger) SetLevel

func (l *Logger) SetLevel(level string) Level

func (*Logger) Trace

func (l *Logger) Trace(msg string, kv ...any)

func (*Logger) Warning

func (l *Logger) Warning(err error, msg string, kv ...any)

type OnCloseFunc

type OnCloseFunc func(*Logger) error

type Option

type Option func(*Logger)

func WithBuildLabelFunc

func WithBuildLabelFunc(fn BuildLabelFunc) Option

func WithLevel

func WithLevel(level string) Option

func WithOnCloseFunc

func WithOnCloseFunc(fn OnCloseFunc) Option

func WithOutput

func WithOutput(o Output) Option

type Output

type Output interface {
	Log(*Record) error
	Close() error
}

func Discard

func Discard() Output

func Stdout

func Stdout() Output

func Syslog

func Syslog(app, facility string) (Output, error)

type Record

type Record struct {
	Time   time.Time
	Logger *Logger
	Level  Level
	Err    error
	Msg    string
	KV     []any
}

func (*Record) Free

func (r *Record) Free()

Jump to

Keyboard shortcuts

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