Documentation
¶
Overview ¶
Package logging provides logging configuration and utility functions.
Index ¶
- func Configure(ctx context.Context, config Config) (*slog.Logger, context.Context)
- func ContextWithLogger(ctx context.Context, logger *slog.Logger) context.Context
- func FromContext(ctx context.Context) *slog.Logger
- func GetLevel() slog.Level
- func Middleware(next http.Handler, config Config) http.Handler
- func SetLevel(level slog.Level)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
Configure sets up logging with the given config and returns the logger and updated context.
func ContextWithLogger ¶
ContextWithLogger returns a new context with the given logger.
func Middleware ¶
Middleware returns an HTTP middleware that logs incoming requests and attaches any configured headers as log attributes.
Types ¶
type Config ¶
type Config struct {
JSON bool `hcl:"json,optional" help:"Enable JSON logging."`
Level slog.Level `hcl:"level" help:"Set the logging level." default:"info"`
Remap map[string]string `hcl:"remap,optional" help:"Remap field names from old to new (e.g., msg=message, time=timestamp)."`
Headers map[string]string `hcl:"headers,optional" help:"Propagate these inbound request headers to the given log attribute."`
}
Click to show internal directories.
Click to hide internal directories.