rich

package
v0.4.2-gz3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugLevel logs everything
	DebugLevel uint32 = iota
	// InfoLevel include debugs
	InfoLevel
	// WarnLevel include debugs, infos
	WarnLevel
	// ErrorLevel includes errors, slows, stacks
	ErrorLevel
)
View Source
const CallerDepth = 4

Variables

This section is empty.

Functions

func AddGlobalFields

func AddGlobalFields(fields ...zapcore.Field)

AddGlobalFields adds global fields.

func ContextWithFields

func ContextWithFields(ctx context.Context, fields ...zapcore.Field) context.Context

ContextWithFields returns a new context with the given fields.

Types

type Logger

type Logger interface {
	// Debuga logs a message at info level.
	Debuga(...any)
	// Debugf logs a message at info level.
	Debugf(string, ...any)
	// Debugv logs a message at info level.
	Debugv(string)
	// Debug logs a message at info level.
	Debug(string, ...zapcore.Field)

	// Infoa logs a message at info level.
	Infoa(...any)
	// Infof logs a message at info level.
	Infof(string, ...any)
	// Infov logs a message at info level.
	Infov(string)
	// Info logs a message at info level.
	Info(string, ...zapcore.Field)

	// Warna logs a message at error level.
	Warna(...any)
	// Warnf logs a message at error level.
	Warnf(string, ...any)
	// Warnv logs a message at error level.
	Warnv(string)
	// Warn logs a message at error level.
	Warn(string, ...zapcore.Field)

	// Errora logs a message at error level.
	Errora(...any)
	// Errorf logs a message at error level.
	Errorf(string, ...any)
	// Errorv logs a message at error level.
	Errorv(string)
	// Errorw logs a message at error level.
	Error(string, ...zapcore.Field)

	// WithCallerSkip returns a new logger with the given caller skip.
	WithCallerSkip(skip int) Logger
	// WithContext returns a new logger with the given context.
	WithContext(ctx context.Context) Logger
	// WithDuration returns a new logger with the given duration.
	WithDuration(d time.Duration) Logger
	// WithFields returns a new logger with the given fields.
	WithFields(fields ...zapcore.Field) Logger
}

A Logger represents a logger.

func NewRichLogger

func NewRichLogger() Logger

func WithCallerSkip

func WithCallerSkip(skip int) Logger

WithCallerSkip returns a Logger with given caller skip.

func WithContext

func WithContext(ctx context.Context) Logger

WithContext sets ctx to log, for keeping tracing information.

func WithDuration

func WithDuration(d time.Duration) Logger

WithDuration returns a Logger with given duration.

func WithLogger

func WithLogger(logger *zap.Logger) Logger

WithLogger returns a Logger with given caller skip.

Jump to

Keyboard shortcuts

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