logging

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: AGPL-3.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyLogger *logger

Functions

func NewLoggingResponseWriter

func NewLoggingResponseWriter(w http.ResponseWriter) *loggingResponseWriter

func NewSlogLogger

func NewSlogLogger(opts SlogOptions) *slog.Logger

Types

type HttpLogger

type HttpLogger struct {
	*slog.Logger
	// contains filtered or unexported fields
}

func NewHttpLogger

func NewHttpLogger(logger *slog.Logger, opts HttpLoggerOptions) *HttpLogger

func (*HttpLogger) Use

func (h *HttpLogger) Use(next http.Handler) http.Handler

type HttpLoggerOptions

type HttpLoggerOptions struct {
	ShowQuery   bool
	ShowHeaders bool
	SilentPaths []string
}

type Logger

type Logger interface {
	Debugf(msg string, args ...any)
	Infof(msg string, args ...any)
	Errorf(err error, args ...any)
	Warnf(msg string, args ...any)
	WithName(name string) Logger
	WithKV(keyValuePairs ...any) Logger
}

func New

func New(options *Options) (Logger, error)

type Options

type Options struct {
	Name string

	Dev bool // deprecated

	ShowDebugLog    bool
	ShowTime        bool
	HideCallerTrace bool
}

type SlogOptions

type SlogOptions struct {
	Writer io.Writer
	Prefix string

	ShowTimestamp bool
	ShowCaller    bool
	ShowDebugLogs bool

	SetAsDefaultLogger bool
}

Jump to

Keyboard shortcuts

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