log

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: GPL-2.0 Imports: 13 Imported by: 80

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithNewID

func ContextWithNewID(ctx context.Context) context.Context

func ContextWithOverrideLevel

func ContextWithOverrideLevel(ctx context.Context, level Level) context.Context

func Debug

func Debug(args ...any)

func DebugContext

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

func Error

func Error(args ...any)

func ErrorContext

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

func Fatal

func Fatal(args ...any)

func FatalContext

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

func FormatLevel

func FormatLevel(level Level) string

func IDFromContext

func IDFromContext(ctx context.Context) (uint32, bool)

func Info

func Info(args ...any)

func InfoContext

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

func Panic

func Panic(args ...any)

func PanicContext

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

func Trace

func Trace(args ...any)

func TraceContext

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

func Warn

func Warn(args ...any)

func WarnContext

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

Types

type ContextLogger

type ContextLogger interface {
	Logger
	TraceContext(ctx context.Context, args ...any)
	DebugContext(ctx context.Context, args ...any)
	InfoContext(ctx context.Context, args ...any)
	WarnContext(ctx context.Context, args ...any)
	ErrorContext(ctx context.Context, args ...any)
	FatalContext(ctx context.Context, args ...any)
	PanicContext(ctx context.Context, args ...any)
}

func StdLogger

func StdLogger() ContextLogger

type Entry

type Entry struct {
	Level   Level
	Message string
}

type Factory

type Factory interface {
	Level() Level
	SetLevel(level Level)
	Logger() ContextLogger
	NewLogger(tag string) ContextLogger
}

func NewFactory

func NewFactory(formatter Formatter, writer io.Writer) Factory

type Formatter

type Formatter struct {
	BaseTime         time.Time
	DisableColors    bool
	DisableTimestamp bool
	FullTimestamp    bool
	TimestampFormat  string
}

func (Formatter) Format

func (f Formatter) Format(ctx context.Context, level Level, tag string, message string, timestamp time.Time) string

func (Formatter) FormatWithSimple

func (f Formatter) FormatWithSimple(ctx context.Context, level Level, tag string, message string, timestamp time.Time) (string, string)

type Level

type Level = uint8
const (
	LevelPanic Level = iota
	LevelFatal
	LevelError
	LevelWarn
	LevelInfo
	LevelDebug
	LevelTrace
)

func OverrideLevelFromContext

func OverrideLevelFromContext(origin Level, ctx context.Context) Level

func ParseLevel

func ParseLevel(level string) (Level, error)

type Logger

type Logger interface {
	Trace(args ...any)
	Debug(args ...any)
	Info(args ...any)
	Warn(args ...any)
	Error(args ...any)
	Fatal(args ...any)
	Panic(args ...any)
}

type ObservableFactory

type ObservableFactory interface {
	Factory
	observable.Observable[Entry]
}

func NewNOPFactory

func NewNOPFactory() ObservableFactory

func NewObservableFactory

func NewObservableFactory(formatter Formatter, writer io.Writer) ObservableFactory

Jump to

Keyboard shortcuts

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