logging

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: AGPL-3.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoggingResponseWriter added in v1.1.0

func NewLoggingResponseWriter(w http.ResponseWriter) *loggingResponseWriter

func NewSlogLogger added in v1.1.0

func NewSlogLogger(opts SlogOptions) *slog.Logger

func ParseLogLevelFromEnv added in v1.1.0

func ParseLogLevelFromEnv(key string) slog.Level

func ParseLogLevelFromString added in v1.1.0

func ParseLogLevelFromString(s string) slog.Level

Types

type HttpLogger added in v1.1.0

type HttpLogger struct {
	HttpLoggerOptions
}

func NewHttpLogger added in v1.1.0

func NewHttpLogger(opts HttpLoggerOptions) *HttpLogger

func (*HttpLogger) Use added in v1.1.0

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

type HttpLoggerOptions added in v1.1.0

type HttpLoggerOptions struct {
	// Logger, can be set if you want to use a different logger than the one provided by the HttpLogger
	Logger *slog.Logger

	// LogLevel, can be set if you want to use a different log level than the one provided by the HttpLogger
	// defaults to log.DebugLevel
	LogLevel    log.Level
	ShowHeaders bool
	SilentPaths []string
}

type Logger

type Logger interface {
	Debugf(msg string, args ...any)
	Infof(msg string, args ...any)
	Errorf(err error, msg string, args ...any)
	Error(err error)
	Warnf(msg string, args ...any)
	WithKV(key string, value any) Logger
	WithName(name string) Logger
	WithOptions(options ...zap.Option) Logger
}

func New

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

func NewOrDie

func NewOrDie(options *Options) Logger

type Options

type Options struct {
	Name        string
	Dev         bool
	CallerTrace bool
}

type SlogOptions added in v1.1.0

type SlogOptions struct {
	Writer io.Writer
	Prefix string

	ShowTimestamp bool
	ShowCaller    bool
	ShowDebugLogs bool
}

Jump to

Keyboard shortcuts

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