logger

package
v0.225.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ChildStderrJSONEnv = "INFER_LOG_STDERR_JSON"

ChildStderrJSONEnv is the environment variable the daemon sets on the processes it starts. A child process then logs JSON to stderr and keeps no log file of its own: the daemon collects its stderr into the daemon log.

Variables

This section is empty.

Functions

func Close

func Close()

Close closes the logger and flushes any buffered entries

func CollectChildStderr added in v0.219.0

func CollectChildStderr(stderr io.Reader, tags ...any) string

CollectChildStderr logs one started child process's stderr into this process's log, one entry per line, enriched with the collector's tags (typically project_dir, conversation_id and worker_pid). It returns once the child's stderr closes, with the child's failure: the error it reported through ReportExitError, or else whatever plain lines it wrote. Plain lines are logged as one warning per child.

func Debug

func Debug(msg string, args ...any)

Debug logs a debug message

func Error

func Error(msg string, args ...any)

Error logs an error message

func ErrorCtx added in v0.207.0

func ErrorCtx(ctx context.Context, msg string, args ...any)

ErrorCtx logs an error carrying the OTel trace context of ctx; see WarnCtx.

func GetGlobalLogger

func GetGlobalLogger() *zap.Logger

GetGlobalLogger returns the global logger instance Useful for services that need to store a logger reference

func Info

func Info(msg string, args ...any)

Info logs an info message

func Init

func Init(cfg Config)

Init initializes the global logger (for migration period)

func NewLogger

func NewLogger(cfg Config) (*zap.Logger, error)

NewLogger creates a new configured logger instance

func ReportExitError added in v0.222.0

func ReportExitError(w io.Writer, err error) bool

ReportExitError writes a failed command's error as one JSON log line on stderr when this process was started by the daemon, so the parent collects the whole message. It reports false when the error should be printed for a person instead.

func SetGlobalLogger

func SetGlobalLogger(l *zap.Logger)

SetGlobalLogger swaps the global logger (and its sugared form). It is primarily a test seam: tests build a logger over an observed core to assert what was logged. Passing nil is a no-op.

func Warn

func Warn(msg string, args ...any)

Warn logs a warning message

func WarnCtx added in v0.207.0

func WarnCtx(ctx context.Context, msg string, args ...any)

WarnCtx logs a warning carrying the OTel trace context of ctx (trace_id, span_id - the field names the OTel spec uses for non-OTLP log formats), so a log line joins the span and metrics recorded for the same operation.

Types

type Config

type Config struct {
	Verbose          bool
	Debug            bool
	LogDir           string
	Stdout           bool
	ArchiveEnabled   bool
	ArchiveMaxSizeMB int
	FilePrefix       string
}

Config for logger initialization

Jump to

Keyboard shortcuts

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