clogger package for structured, leveled logging. You may inject clogger.Logger anywhere you need it, and every scaffolded router and service already has one.
Writing Logs
There are four levels.Debug and Info take just a message, while Warn and Error also take an error, which may be nil:
WithTags:
Configuration
The logger is configured under the[clogger] section:
In JSON format, each log is a single object with
ts, level, msg, error, and tags, ready for a log aggregator.
Redacting Sensitive Fields
In JSON format,redact_fields replaces matching tag values with "redacted" anywhere in the tag tree, including nested objects. Field names match loosely, so redact_fields = ["email"] also catches user_email and emailAddress:
Hooks
If you would like to ship logs to an external service, such as an error tracker or a cloud logging platform, implementclogger.Hook:
[]clogger.Hook in your app’s wire module:
pkg/app/logger.go