log

package
v0.0.0-...-e3220b9 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToContext

func AppendToContext(ctx context.Context, attrs ...any) context.Context

AppendToContext append logging attributes to the given context.

func AttrsFromContext

func AttrsFromContext(ctx context.Context) []any

AttrsFromContext retrieve log attributes from context if any.

func Debug

func Debug(msg string, args ...any)

Debug calls Logger.Debug on the default logger.

func DebugContext

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

DebugContext calls Logger.DebugContext on the default logger.

func Error

func Error(msg string, args ...any)

Error calls Logger.Error on the default logger.

func ErrorContext

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

ErrorContext calls Logger.ErrorContext on the default logger.

func Info

func Info(msg string, args ...any)

Info calls Logger.Info on the default logger.

func InfoContext

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

InfoContext calls Logger.InfoContext on the default logger.

func Log

func Log(ctx context.Context, level slog.Level, msg string, args ...any)

Log calls Logger.Log on the default logger.

func LogAttrs

func LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)

LogAttrs calls Logger.LogAttrs on the default logger.

func NewAttrsContext

func NewAttrsContext(ctx context.Context, attrs ...any) context.Context

NewAttrsContext return new logging attributes context.

func NewContext

func NewContext(ctx context.Context, logger *Logger) context.Context

NewContext return new context with the given logger inside.

func SetDefault

func SetDefault(log *Logger)

func Warn

func Warn(msg string, args ...any)

Warn calls Logger.Warn on the default logger.

func WarnContext

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

WarnContext calls Logger.WarnContext on the default logger.

Types

type Logger

type Logger struct {
	*slog.Logger
}

func Default

func Default() *Logger

func FromContext

func FromContext(ctx context.Context) *Logger

FromContext return logger from the given context if exist

func Named

func Named(name string) *Logger

func New

func New(logger *slog.Logger) *Logger

func (*Logger) DebugContext

func (logger *Logger) DebugContext(ctx context.Context, msg string, args ...any)

func (*Logger) ErrorContext

func (logger *Logger) ErrorContext(ctx context.Context, msg string, args ...any)

func (*Logger) InfoContext

func (logger *Logger) InfoContext(ctx context.Context, msg string, args ...any)

func (*Logger) Log

func (logger *Logger) Log(ctx context.Context, level slog.Level, msg string, args ...any)

func (*Logger) LogAttrs

func (logger *Logger) LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)

func (*Logger) WarnContext

func (logger *Logger) WarnContext(ctx context.Context, msg string, args ...any)

func (*Logger) With

func (logger *Logger) With(args ...any) *Logger

func (*Logger) WithGroup

func (logger *Logger) WithGroup(name string) *Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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