log

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, args ...any)

func Debugf

func Debugf(ctx context.Context, template string, args ...any)

func Error

func Error(ctx context.Context, args ...any)

func Errorf

func Errorf(ctx context.Context, template string, args ...any)

func Fatal

func Fatal(ctx context.Context, args ...any)

func Fatalf

func Fatalf(ctx context.Context, template string, args ...any)

func Info

func Info(ctx context.Context, args ...any)

func Infof

func Infof(ctx context.Context, template string, args ...any)

func Panic

func Panic(ctx context.Context, args ...any)

func Panicf

func Panicf(ctx context.Context, template string, args ...any)

func RegisterLogger

func RegisterLogger(newLogger Logger)

RegisterLogger by constructing Logger via NewLogger, global Logger is disabled by default

func Sync

func Sync() error

func Warn

func Warn(ctx context.Context, args ...any)

func Warnf

func Warnf(ctx context.Context, template string, args ...any)

Types

type ContextWriter

type ContextWriter[T any] interface {
	With(key string, value any) T
	Debug(ctx context.Context, args ...any)
	Debugf(ctx context.Context, template string, args ...any)
	Info(ctx context.Context, args ...any)
	Infof(ctx context.Context, template string, args ...any)
	Warn(ctx context.Context, args ...any)
	Warnf(ctx context.Context, template string, args ...any)
	Error(ctx context.Context, args ...any)
	Errorf(ctx context.Context, template string, args ...any)
	Panic(ctx context.Context, args ...any)
	Panicf(ctx context.Context, template string, args ...any)
	Fatal(ctx context.Context, args ...any)
	Fatalf(ctx context.Context, template string, args ...any)
}

type Level

type Level string
const (
	DebugLevel Level = "debug"
	InfoLevel  Level = "info"
	WarnLevel  Level = "warn"
	ErrorLevel Level = "error"
)

func (Level) ToZapAtomic

func (lvl Level) ToZapAtomic() zap.AtomicLevel

type Logger

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

func NewLogger

func NewLogger(params Params) (Logger, error)

func NewNoopLogger

func NewNoopLogger() Logger

func With

func With(key string, value any) Logger

func (Logger) Debug

func (l Logger) Debug(ctx context.Context, args ...any)

func (Logger) Debugf

func (l Logger) Debugf(ctx context.Context, template string, args ...any)

func (Logger) Error

func (l Logger) Error(ctx context.Context, args ...any)

func (Logger) Errorf

func (l Logger) Errorf(ctx context.Context, template string, args ...any)

func (Logger) Fatal

func (l Logger) Fatal(ctx context.Context, args ...any)

func (Logger) Fatalf

func (l Logger) Fatalf(ctx context.Context, template string, args ...any)

func (Logger) Info

func (l Logger) Info(ctx context.Context, args ...any)

func (Logger) Infof

func (l Logger) Infof(ctx context.Context, template string, args ...any)

func (Logger) NoContext

func (l Logger) NoContext() Writer[noContextLogger]

func (Logger) Panic

func (l Logger) Panic(ctx context.Context, args ...any)

func (Logger) Panicf

func (l Logger) Panicf(ctx context.Context, template string, args ...any)

func (Logger) Sync

func (l Logger) Sync() error

func (Logger) Warn

func (l Logger) Warn(ctx context.Context, args ...any)

func (Logger) Warnf

func (l Logger) Warnf(ctx context.Context, template string, args ...any)

func (Logger) With

func (l Logger) With(key string, value any) Logger

type Params

type Params struct {
	Env   sre.Env
	Level Level
}

func NewParams

func NewParams(env sre.Env, lvl Level) Params

type Writer

type Writer[T any] interface {
	With(key string, value any) T
	Debug(args ...any)
	Debugf(template string, args ...any)
	Info(args ...any)
	Infof(template string, args ...any)
	Warn(args ...any)
	Warnf(template string, args ...any)
	Error(args ...any)
	Errorf(template string, args ...any)
	Panic(args ...any)
	Panicf(template string, args ...any)
	Fatal(args ...any)
	Fatalf(template string, args ...any)
}

func NoContext

func NoContext() Writer[noContextLogger]

Jump to

Keyboard shortcuts

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