Documentation
¶
Index ¶
- func MustParseLevel(lvlStr string) slog.Level
- func PrintDroppedLogs(ctx context.Context, interval time.Duration, r *RateLimitHandler, ...)
- type ExportHandler
- func (h *ExportHandler) Enabled(ctx context.Context, level slog.Level) bool
- func (h *ExportHandler) Handle(ctx context.Context, record slog.Record) error
- func (h *ExportHandler) Records() <-chan slog.Record
- func (h *ExportHandler) Register(next slog.Handler) slog.Handler
- func (h *ExportHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *ExportHandler) WithGroup(name string) slog.Handler
- type ExportHandlerConfig
- type Handler
- type HandlerFunc
- type Logger
- func (l *Logger) Debug(msg string)
- func (l *Logger) Debugf(format string, a ...any)
- func (l *Logger) Error(msg string)
- func (l *Logger) Errorf(format string, a ...any)
- func (l *Logger) Fatal(msg string)
- func (l *Logger) Fatalf(msg string, a ...any)
- func (l *Logger) Info(msg string)
- func (l *Logger) Infof(format string, a ...any)
- func (l *Logger) IsEnabled(lvl slog.Level) bool
- func (l *Logger) Warn(msg string)
- func (l *Logger) Warnf(format string, a ...any)
- func (l *Logger) With(args ...any) *Logger
- func (l *Logger) WithField(k, v string) *Logger
- func (l *Logger) WithGroup(name string) *Logger
- type RateLimitHandler
- func (h *RateLimitHandler) Enabled(ctx context.Context, level slog.Level) bool
- func (h *RateLimitHandler) Handle(ctx context.Context, record slog.Record) error
- func (h *RateLimitHandler) Register(next slog.Handler) slog.Handler
- func (h *RateLimitHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *RateLimitHandler) WithGroup(name string) slog.Handler
- type RateLimiterHandlerConfig
- type TextHandlerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustParseLevel ¶
func PrintDroppedLogs ¶
func PrintDroppedLogs(ctx context.Context, interval time.Duration, r *RateLimitHandler, printFunc func(level slog.Level, count uint64))
PrintDroppedLogs prints dropped rate limit logs and resets counter to 0.
Types ¶
type ExportHandler ¶
type ExportHandler struct {
// contains filtered or unexported fields
}
ExportHandler exports logs to separate channel available via Records()
func NewExportHandler ¶
func NewExportHandler(cfg ExportHandlerConfig) *ExportHandler
func (*ExportHandler) Records ¶
func (h *ExportHandler) Records() <-chan slog.Record
type ExportHandlerConfig ¶
type Handler ¶
Handler allows to chain multiple handlers. Order of execution is reverse to order of registration meaning first handler is executed last.
func NewTextHandler ¶
func NewTextHandler(cfg TextHandlerConfig) Handler
NewTextHandler returns slog text handler.
type HandlerFunc ¶
type Logger ¶
Logger is a small wrapper around slog with some extra methods for easier migration from logrus.
type RateLimitHandler ¶
type RateLimitHandler struct {
// contains filtered or unexported fields
}
func NewRateLimitHandler ¶
func NewRateLimitHandler(cfg RateLimiterHandlerConfig) *RateLimitHandler
func (*RateLimitHandler) Register ¶
func (h *RateLimitHandler) Register(next slog.Handler) slog.Handler
Click to show internal directories.
Click to hide internal directories.