logger

package
v1.6.15 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMiddleware added in v1.6.14

func NewMiddleware(log *slog.Logger) func(http.HandlerFunc) http.HandlerFunc

NewMiddleware returns an HTTP middleware function that logs each request. If log is nil, slog.Default() is used.

Types

type ResponseWriter

type ResponseWriter interface {
	http.ResponseWriter

	// Status returns the status code of the response or 0 if the response has
	// not been written
	Status() int

	// Written returns whether or not the ResponseWriter has been written.
	Written() bool

	// Size returns the size of the response body.
	Size() int
}

ResponseWriter is a wrapper around http.ResponseWriter that provides extra information about the response. It is recommended that middleware handlers use this construct to wrap a responsewriter if the functionality calls for it.

func NewResponseWriter

func NewResponseWriter(rw http.ResponseWriter) ResponseWriter

NewResponseWriter creates a ResponseWriter that wraps a http.ResponseWriter

type TermHandler

type TermHandler struct {
	io.Writer
	// contains filtered or unexported fields
}

func NewTermHandler added in v1.6.14

func NewTermHandler(w io.Writer, level *slog.LevelVar) *TermHandler

func (*TermHandler) Enabled

func (h *TermHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*TermHandler) Handle

func (h *TermHandler) Handle(ctx context.Context, r slog.Record) error

func (*TermHandler) WithAttrs

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

func (*TermHandler) WithGroup

func (h *TermHandler) WithGroup(name string) slog.Handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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