logger

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 12 Imported by: 2

README

logger

Go Reference

TODO


Copyright (c) 2022 Archivage Numérique

Documentation

Overview

Package logger TODO

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 Log

func Log(o Output, r *Record) error

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 uint64
const (
	LevelTrace Level
	LevelDebug
	LevelInfo
	LevelNotice
	LevelWarning
	LevelError
	LevelFatal
)

func SetLevel

func SetLevel(id, level string) (Level, error)

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 added in v0.4.0

func (l *Logger) Close() error

func (*Logger) Debug

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

func (*Logger) Deregister

func (l *Logger) Deregister()

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) Register

func (l *Logger) Register() error

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 LoggerInfo

type LoggerInfo struct {
	ID    string
	Name  string
	Level string
}

func List

func List() []*LoggerInfo

type OnCloseFunc added in v0.4.0

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 added in v0.4.0

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 {
	TS     time.Time
	Label  string
	Level  Level
	Err    error
	Msg    string
	KV     []any
	ToFree bool
}

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