logger

package
v1.5.17 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 11 Imported by: 1

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

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