Help us shape the future of Go! Take the 2026 Go Developer Survey

log

package
v0.51.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

View Source
const SkipOTLPKey = "otlp_skip"

SkipOTLPKey is the attribute key behind SkipOTLP.

Variables

View Source
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 Debug

func Debug(msg string)

Debug logs msg at debug level.

func Debugf

func Debugf(format string, args ...any)

Debugf logs a formatted message at debug level.

func Enabled

func Enabled(lvl slog.Level) bool

Enabled reports whether records at lvl are logged, so hot paths can skip building attributes for records that would be dropped.

func Error

func Error(msg string)

Error logs msg at error level.

func Errorf

func Errorf(format string, args ...any)

Errorf logs a formatted message at error level.

func Fatal

func Fatal(msg string)

Fatal logs msg at error level, runs the BeforeExit hooks and exits with status 1.

func Fatalf

func Fatalf(format string, args ...any)

Fatalf logs a formatted message at error level, runs the BeforeExit hooks and exits with status 1.

func ForOTLP

func ForOTLP(h slog.Handler) slog.Handler

ForOTLP wraps h, a handler that exports records off the host, so that it honors the configured level and drops records marked SkipOTLP.

func Info

func Info(msg string)

Info logs msg at info level.

func Infof

func Infof(format string, args ...any)

Infof logs a formatted message at info level.

func SetLevel

func SetLevel(lvl slog.Level)

SetLevel changes the level of every installed handler.

func Setup

func Setup(w io.Writer, format string, lvl slog.Level)

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.

func Tee

func Tee(h slog.Handler)

Tee additionally sends every record to h. Wrap an exporting handler with ForOTLP so the configured level and SkipOTLP apply to it.

func Warn

func Warn(msg string)

Warn logs msg at warn level.

func Warnf

func Warnf(format string, args ...any)

Warnf logs a formatted message at warn level.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL