Documentation
¶
Overview ¶
Package logx builds an slog logger configured the same way in every project.
Index ¶
Constants ¶
const AlertKey = "alert"
AlertKey is the attribute that raises an alert from an ordinary log line:
log.ErrorContext(ctx, "the pool is empty", logx.AlertKey, "pool_empty")
Its value is the alert kind. The platform counts such lines in app_alerts_total{kind}, so a use case needs no metric of its own to page someone.
Variables ¶
This section is empty.
Functions ¶
func Alerts ¶ added in v0.5.7
Alerts wraps a handler: count receives the kind of every record that carries AlertKey, either in the record itself or in attributes added with With. Attributes inside a group are not top level and do not count. The record is passed on unchanged.
An alert is counted whatever the log level: a service running with LOG_LEVEL=error still counts a warning that raised one, though the line itself is not written. Debug lines are the exception, so that disabled debug logging stays free.