Overview of slog-formatter components
mainThe library is organized into three main categories of functionality:
Handlers and Middlewares
NewFormatterHandler: The primary entry point to wrap an existingslog.Handlerwith formatting logic.NewFormatterMiddleware: A middleware compatible withslog-multifor advanced handler chaining.RecoverHandlerError: A specialized handler to catch panics and errors occurring within other handlers.
Common Formatters
Pre-built formatters for standard types and common tasks:
- Time:
TimeFormatter(readable strings),UnixTimestampFormatter(unix timestamps), andTimezoneConverter(timezone adjustment). - Errors:
ErrorFormatterfor transforming Go errors. - HTTP:
HTTPRequestFormatterandHTTPResponseFormatterfor logging web traffic. - Security/Privacy:
PIIFormatter(hide PII) andIPAddressFormatter(hide IP addresses). - Structure:
FlattenFormatterMiddlewareto recursively flatten attributes.