logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logger configures structured logging for the agent using log/slog.

Design decisions:

  • JSON output by default for log aggregation (journald, Loki, Datadog)
  • Text output when LOG_FORMAT=text (local development)
  • Level controlled by LOG_LEVEL env var (debug, info, warn, error)
  • Structured fields: environment, phase, digest, duration included consistently

Index

Constants

View Source
const (
	PhasePoll        = "poll"
	PhaseDrift       = "drift_check"
	PhasePull        = "image_pull"
	PhaseStrategy    = "deployment_strategy"
	PhaseMigration   = "migration"
	PhaseRestart     = "restart"
	PhaseHealthCheck = "health_check"
	PhaseCommit      = "commit"
	PhaseRollback    = "rollback"
	PhaseNoop        = "noop"
)

Phase constants for structured log fields. Using constants prevents typos and enables log-based alerting rules.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *slog.Logger

FromContext retrieves the logger stored in ctx. Falls back to the default slog logger if none is stored.

func Setup

func Setup() *slog.Logger

Setup configures the default global slog logger. Call once at startup before spawning goroutines.

func WithContainerName

func WithContainerName(logger *slog.Logger, containerName string) *slog.Logger

WithContainerName returns a child logger with the environment field pre-set. All log lines emitted from the reconciler for an environment will carry this.

func WithContext

func WithContext(ctx context.Context, logger *slog.Logger) context.Context

WithContext stores logger in ctx, enabling logger retrieval in deep call stacks.

Types

This section is empty.

Jump to

Keyboard shortcuts

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