logging
import "github.com/Ask-Atlas/AskAtlas/api/internal/logging"
Package logging provides a configurable structured logger using slog.
Index
- func NewLogger(opts ...Option) *slog.Logger
- func RequestLogger(log *slog.Logger) func(http.Handler) http.Handler
- type Option
func NewLogger
func NewLogger(opts ...Option) *slog.Logger
NewLogger instantiates a new configured slog instance.
func RequestLogger
func RequestLogger(log *slog.Logger) func(http.Handler) http.Handler
RequestLogger returns an HTTP middleware that logs the method, path, status, and duration of requests.
type Option
Option defines a functional configuration option for the logger.
type Option func(*loggerConfig)
func WithAddSource
func WithAddSource(addSource bool) Option
WithAddSource controls whether logged items include the calling source file and line.
func WithEnv
func WithEnv(env string) Option
WithEnv sets the environment string.
func WithHandler
func WithHandler(handler slog.Handler) Option
WithHandler explicitly sets the underlying slog.Handler, bypassing the defaults.
func WithLevel
func WithLevel(level slog.Level) Option
WithLevel sets the minimum logging severity level.
func WithWriter
func WithWriter(writer io.Writer) Option
WithWriter changes the output destination from the default os.Stdout.
Generated by gomarkdoc