logging

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustParseLevel

func MustParseLevel(lvlStr string) slog.Level

func NewExportHandler

func NewExportHandler(ctx context.Context, next slog.Handler, cfg ExportConfig) slog.Handler

func NewRateLimiterHandler

func NewRateLimiterHandler(ctx context.Context, next slog.Handler, cfg RateLimiterConfig) slog.Handler

Types

type Config

type Config struct {
	Ctx         context.Context
	RateLimiter RateLimiterConfig
	Level       slog.Level
	AddSource   bool
	Output      io.Writer
	Export      ExportConfig
}

type ExportConfig

type ExportConfig struct {
	ExportFunc ExportFunc
	MinLevel   slog.Level
}

type ExportFunc

type ExportFunc func(ctx context.Context, record slog.Record)

type ExportHandler

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

func (*ExportHandler) Enabled

func (e *ExportHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*ExportHandler) Handle

func (e *ExportHandler) Handle(ctx context.Context, record slog.Record) error

func (*ExportHandler) WithAttrs

func (e *ExportHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*ExportHandler) WithGroup

func (e *ExportHandler) WithGroup(name string) slog.Handler

type Logger

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

func New

func New(cfg *Config) *Logger

func NewTestLog

func NewTestLog() *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string)

func (*Logger) Debugf

func (l *Logger) Debugf(format string, a ...any)

func (*Logger) Error

func (l *Logger) Error(msg string)

func (*Logger) Errorf

func (l *Logger) Errorf(format string, a ...any)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

func (*Logger) Info

func (l *Logger) Info(msg string)

func (*Logger) Infof

func (l *Logger) Infof(format string, a ...any)

func (*Logger) IsEnabled

func (l *Logger) IsEnabled(lvl slog.Level) bool

func (*Logger) Warn

func (l *Logger) Warn(msg string)

func (*Logger) Warnf

func (l *Logger) Warnf(format string, a ...any)

func (*Logger) With

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

func (*Logger) WithField

func (l *Logger) WithField(k, v string) *Logger

type RateLimiterConfig

type RateLimiterConfig struct {
	Limit  rate.Limit
	Burst  int
	Inform bool
}

type RateLimiterHandler

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

func (*RateLimiterHandler) Enabled

func (s *RateLimiterHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*RateLimiterHandler) Handle

func (s *RateLimiterHandler) Handle(ctx context.Context, record slog.Record) error

func (*RateLimiterHandler) WithAttrs

func (s *RateLimiterHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*RateLimiterHandler) WithGroup

func (s *RateLimiterHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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