logging

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: AGPL-3.0 Imports: 10 Imported by: 2 modules, 4 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

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