Documentation
¶
Overview ¶
Package logger provides a preinitialized slog logger ready for use.
Additionally it provides middlewares for use with http handlers to record access logs.
Index ¶
- Constants
- func AccessLogMiddleware(next http.Handler) http.Handler
- func ContextWithAttr(parent context.Context, attr slog.Attr) context.Context
- func Err(err error) slog.Attr
- func InitLogger(writer io.Writer, filepath string, verbose bool, debug bool) error
- func RequestIDMiddleware(next http.Handler) http.Handler
Constants ¶
View Source
const LevelTrace slog.Level = -8
View Source
const MaximumValueLength = 2000
Variables ¶
This section is empty.
Functions ¶
func ContextWithAttr ¶
ContextWithAttr returns a copy of parent in which the attr is added to the list of slog attributes attached to the context.
Use context slog attributes only for request-scoped log attributes.
func Err ¶
Err is a helper function to ensure errors are always logged with the key "err". Additionally this becomes the single point in code, where we could tweak how errors are logged, e.g. to handle application specific error types or to add stack trace information in debug mode.
func InitLogger ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.