logger

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 11 Imported by: 6 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format uint
const (
	Text Format = iota
	JSON
	Term
)

type Logger

type Logger struct {
	*slog.Logger
}

func New

func New(w io.Writer, f Format, debug bool) *Logger

func (*Logger) Debug

func (t *Logger) Debug(ctx context.Context, args ...any)

Emit a debugging message

func (*Logger) Debugf

func (t *Logger) Debugf(ctx context.Context, f string, args ...any)

Emit a debugging message with formatting

func (*Logger) HandleFunc added in v1.5.6

func (t *Logger) HandleFunc(next http.HandlerFunc) http.HandlerFunc

func (*Logger) Print

func (t *Logger) Print(ctx context.Context, args ...any)

Emit an informational message

func (*Logger) Printf

func (t *Logger) Printf(ctx context.Context, f string, args ...any)

Emit an informational message with formatting

func (*Logger) With

func (t *Logger) With(kv ...any) server.Logger

Append structured data to the log in key-value pairs where the key is a string and the value is any type

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
	slog.Level
	// contains filtered or unexported fields
}

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