What's New
v1.0.0 (unreleased)
Initial release. Stable API; SemVer applies from this point forward.
LogLayer for Go is a transport-agnostic structured logging facade. One fluent API on top of any logging library, JSON, terminal, HTTP, OpenTelemetry, or your own transport.
What ships
- Core API: fluent builder with persistent fields, per-call metadata, errors, Go context, and group routing. Seven log levels (Trace through Panic). Every method safe from any goroutine. See Getting Started.
- Renderers: pretty, structured, console, testing, blank.
- Logger wrappers: zerolog, zap, log/slog, logrus, charmbracelet/log, phuslu/log.
- Network transports: HTTP, Datadog.
- OpenTelemetry:
transports/otellogships through the OTel logs pipeline;plugins/oteltraceinjectstrace_id/span_idon any transport. - Plugins: redact, sampling, fmtlog, datadogtrace, oteltrace. Six lifecycle hooks with centralized panic recovery; author your own per Creating Plugins.
- HTTP middleware:
integrations/loghttpbinds a per-request logger tor.Context()and logs each response. - slog interop:
integrations/sloghandlerroutes everyslog.Info(...)call (yours and your dependencies') through the loglayer pipeline. Pairs with the slog transport for the opposite direction. - stdlib log bridge:
log.Writer(level)/log.NewLogLogger(level)plumb anything that wants a*log.Loggerorio.Writer(http.Server.ErrorLog, gorm, etc.) through loglayer. - Error chain expansion: opt-in
loglayer.UnwrappingErrorSerializersurfaces every wrapped cause as acausesarray. - Source / caller info: opt-in via
Config.Source.Enabled; the slog handler forwardsRecord.PCfor free. - Runtime control: live and concurrency-safe level changes, transport hot-swap, plugin add/remove, mute toggles.
- Opt-in transport panic recovery:
Config.OnTransportPanicabsorbs panics fromSendToLoggerso one bad sink can't suppress the others. - Defensive defaults: CRLF / ANSI / Unicode-bidi sanitization in console and pretty, cross-host redirect refusal on the HTTP transport, redacted Datadog API key, cycle-safe
maputil.Cloner.
For Go users coming from the TypeScript loglayer library, see For TypeScript Developers for the API mapping.
