Skip to content

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/otellog ships through the OTel logs pipeline; plugins/oteltrace injects trace_id/span_id on any transport.
  • Plugins: redact, sampling, fmtlog, datadogtrace, oteltrace. Six lifecycle hooks with centralized panic recovery; author your own per Creating Plugins.
  • HTTP middleware: integrations/loghttp binds a per-request logger to r.Context() and logs each response.
  • slog interop: integrations/sloghandler routes every slog.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.Logger or io.Writer (http.Server.ErrorLog, gorm, etc.) through loglayer.
  • Error chain expansion: opt-in loglayer.UnwrappingErrorSerializer surfaces every wrapped cause as a causes array.
  • Source / caller info: opt-in via Config.Source.Enabled; the slog handler forwards Record.PC for free.
  • Runtime control: live and concurrency-safe level changes, transport hot-swap, plugin add/remove, mute toggles.
  • Opt-in transport panic recovery: Config.OnTransportPanic absorbs panics from SendToLogger so 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.