log

package
v0.0.0-...-01d4da0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MulanPSL-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = NewStdLogger(log.Writer())
View Source
var DefaultMessageKey = "msg"

DefaultMessageKey default message key.

Functions

func Debug

func Debug(a ...any)

Debug logs a message at debug level.

func Debugf

func Debugf(format string, a ...interface{})

Debugf logs a message at debug level.

func Debugw

func Debugw(keyvals ...interface{})

Debugw logs a message at debug level.

func Error

func Error(a ...interface{})

Error logs a message at error level.

func Errorf

func Errorf(format string, a ...interface{})

Errorf logs a message at error level.

func Errorw

func Errorw(keyvals ...interface{})

Errorw logs a message at error level.

func Fatal

func Fatal(a ...interface{})

Fatal logs a message at fatal level.

func Fatalf

func Fatalf(format string, a ...interface{})

Fatalf logs a message at fatal level.

func Fatalw

func Fatalw(keyvals ...interface{})

Fatalw logs a message at fatal level.

func Info

func Info(a ...interface{})

Info logs a message at info level.

func Infof

func Infof(format string, a ...interface{})

Infof logs a message at info level.

func Infow

func Infow(keyvals ...interface{})

Infow logs a message at info level.

func Log

func Log(level Level, keyvals ...any)

func NewWriter

func NewWriter(logger Logger, opts ...WriterOptionFn) io.Writer

func SetLogger

func SetLogger(logger Logger)

func Value

func Value(ctx context.Context, v any) any

func Warn

func Warn(a ...interface{})

Warn logs a message at warn level.

func Warnf

func Warnf(format string, a ...interface{})

Warnf logs a message at warnf level.

func Warnw

func Warnw(keyvals ...interface{})

Warnw logs a message at warnf level.

Types

type Filter

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

func NewFilter

func NewFilter(logger Logger, opts ...FilterOption) *Filter

func (*Filter) Log

func (f *Filter) Log(level Level, keyvals ...any) error

type FilterOption

type FilterOption func(*Filter)

func FilterFunc

func FilterFunc(f func(level Level, keyvals ...any) bool) FilterOption

func FilterKey

func FilterKey(key ...any) FilterOption

func FilterLevel

func FilterLevel(level Level) FilterOption

func FilterValue

func FilterValue(value ...any) FilterOption

type Helper

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

func Context

func Context(ctx context.Context) *Helper

func NewHelper

func NewHelper(logger Logger, opts ...Option) *Helper

func (*Helper) Debug

func (h *Helper) Debug(a ...any)

func (*Helper) Debugf

func (h *Helper) Debugf(format string, a ...any)

func (*Helper) Debugw

func (h *Helper) Debugw(keyvals ...any)

func (*Helper) Error

func (h *Helper) Error(a ...interface{})

Error logs a message at error level.

func (*Helper) Errorf

func (h *Helper) Errorf(format string, a ...interface{})

Errorf logs a message at error level.

func (*Helper) Errorw

func (h *Helper) Errorw(keyvals ...interface{})

Errorw logs a message at error level.

func (*Helper) Fatal

func (h *Helper) Fatal(a ...interface{})

Fatal logs a message at fatal level.

func (*Helper) Fatalf

func (h *Helper) Fatalf(format string, a ...interface{})

Fatalf logs a message at fatal level.

func (*Helper) Fatalw

func (h *Helper) Fatalw(keyvals ...interface{})

Fatalw logs a message at fatal level.

func (*Helper) Info

func (h *Helper) Info(a ...any)

func (*Helper) Infos

func (h *Helper) Infos(format string, a ...any)

func (*Helper) Infow

func (h *Helper) Infow(keyvals ...interface{})

Infow logs a message at info level.

func (*Helper) Log

func (h *Helper) Log(level Level, keyvals ...any)

func (*Helper) Warn

func (h *Helper) Warn(a ...interface{})

Warn logs a message at warn level.

func (*Helper) Warnf

func (h *Helper) Warnf(format string, a ...interface{})

Warnf logs a message at warnf level.

func (*Helper) Warnw

func (h *Helper) Warnw(keyvals ...interface{})

Warnw logs a message at warnf level.

func (*Helper) WithContext

func (h *Helper) WithContext(ctx context.Context) *Helper

type Level

type Level int8
const (
	LevelDebug Level = iota - 1
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

func ParseLevel

func ParseLevel(s string) Level

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	Log(level Level, keyvals ...any) error
}

func GetLogger

func GetLogger() Logger

func NewStdLogger

func NewStdLogger(w io.Writer) Logger

func With

func With(l Logger, kv ...any) Logger

func WithContext

func WithContext(ctx context.Context, l Logger) Logger

WithContext returns a shallow copy of l with its context changed to ctx. The provided ctx must be non-nil.

type Option

type Option func(*Helper)

func WithMessageKey

func WithMessageKey(k string) Option

type Valuer

type Valuer func(ctx context.Context) any

func Caller

func Caller(depth int) Valuer

func Timestamp

func Timestamp(layout string) Valuer

type WriterOptionFn

type WriterOptionFn func(w *writerWrapper)

func WithWriterLevel

func WithWriterLevel(level Level) WriterOptionFn

func WithWriterMessageKey

func WithWriterMessageKey(key string) WriterOptionFn

Jump to

Keyboard shortcuts

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