slogdiscard

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package slogdiscard provides a no-op logger and handler for the Go 'slog' package. Useful for disabling log output in testing or production when logging is not desired.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct{}

Handler is a no-op implementation of slog.Handler.DiscardHandler

func NewHandler

func NewHandler(_ io.Writer, _ *slog.HandlerOptions) *Handler

NewHandler returns a new instance of discard handler.

func (*Handler) Enabled

func (h *Handler) Enabled(_ context.Context, _ slog.Level) bool

Enabled reports whether a record at the given level should be logged. Always returns false, meaning no log records are ever enabled.

func (*Handler) Handle

func (h *Handler) Handle(_ context.Context, _ slog.Record) error

Handle receives a log record and does nothing with it. Always returns nil, indicating no error but no action taken.

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(_ []slog.Attr) slog.Handler

WithAttrs returns the same discard handler instance. Since no attributes are ever used, this method has no effect.

func (*Handler) WithGroup

func (h *Handler) WithGroup(_ string) slog.Handler

WithGroup returns the same discard handler instance. Grouping is ignored, as all logs are discarded.

Jump to

Keyboard shortcuts

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