Documentation
¶
Overview ¶
Package log is parca-agent's logging front end: printf-style helpers over the process-wide slog logger, the same shape as the profiler's own log package, plus the setup that points the profiler's logger at the same handlers. Structured call sites can use log/slog directly; both end up in the handlers installed here.
Index ¶
- Constants
- Variables
- func BeforeExit(f func())
- func Debug(msg string)
- func Debugf(format string, args ...any)
- func Enabled(lvl slog.Level) bool
- func Error(msg string)
- func Errorf(format string, args ...any)
- func Fatal(msg string)
- func Fatalf(format string, args ...any)
- func ForOTLP(h slog.Handler) slog.Handler
- func Info(msg string)
- func Infof(format string, args ...any)
- func SetLevel(lvl slog.Level)
- func Setup(w io.Writer, format string, lvl slog.Level)
- func Tee(h slog.Handler)
- func Warn(msg string)
- func Warnf(format string, args ...any)
Constants ¶
const SkipOTLPKey = "otlp_skip"
SkipOTLPKey is the attribute key behind SkipOTLP.
Variables ¶
var SkipOTLP = slog.Bool(SkipOTLPKey, true)
SkipOTLP marks a record as local-only: handlers wrapped with ForOTLP drop records that carry it, so high-volume debug output stays on stderr. Add it as an attribute, e.g. slog.Debug("probe fire", log.SkipOTLP, ...).
Functions ¶
func BeforeExit ¶
func BeforeExit(f func())
BeforeExit registers f to run before Fatal exits the process, e.g. to flush records that have not been exported yet.
func Enabled ¶
Enabled reports whether records at lvl are logged, so hot paths can skip building attributes for records that would be dropped.
func Fatal ¶
func Fatal(msg string)
Fatal logs msg at error level, runs the BeforeExit hooks and exits with status 1.
func Fatalf ¶
Fatalf logs a formatted message at error level, runs the BeforeExit hooks and exits with status 1.
func ForOTLP ¶
ForOTLP wraps h, a handler that exports records off the host, so that it honors the configured level and drops records marked SkipOTLP.
func Setup ¶
Setup installs a handler writing to w in format ("logfmt" or "json") at lvl as the process-wide logger, for the agent and the profiler. Records logged through the standard library's log package land there too.
Types ¶
This section is empty.