Description
urunc currently uses standard Go logging (log package or fmt.Printf) throughout the codebase. This produces unstructured, plain-text logs that are difficult to filter, query, or aggregate in production deployments.
Go 1.21 introduced log/slog, the standard structured logging package. Migrating to slog would enable leveled logging (Debug, Info, Warn, Error), structured key-value pairs, and JSON output.... all without external dependencies.
Proposed Work
- Introduce a centralized logger in
pkg/ or internal/ using log/slog.
- Replace
log.Printf / fmt.Printf logging calls with slog.Info, slog.Debug, slog.Error across:
pkg/unikontainers/ (VM lifecycle, network, initrd)
pkg/containerd-shim/ (shim operations)
cmd/urunc/ (CLI commands)
- Add a
--log-format flag to urunc CLI supporting text (default) and json.
- Add a
--log-level flag supporting debug, info, warn, error.
Why This Matters
- Structured logs enable filtering and aggregation in production (e.g., "show all ERROR logs from network setup").
- JSON output integrates with log aggregation systems (ELK, Loki, CloudWatch).
- Aligns with modern Go practices (
runc, containerd both use structured logging).
- Zero external dependencies
slog is in the standard library.
Acceptance Criteria
Non-Priorities
- Adding new logging frameworks (zap, zerolog, etc.)
slog only.
- Changing error handling logic.
- Adding new features beyond logging.
I can start with pkg/unikontainers/ and then move on from there...
Description
urunccurrently uses standard Go logging (logpackage orfmt.Printf) throughout the codebase. This produces unstructured, plain-text logs that are difficult to filter, query, or aggregate in production deployments.Go 1.21 introduced
log/slog, the standard structured logging package. Migrating toslogwould enable leveled logging (Debug, Info, Warn, Error), structured key-value pairs, and JSON output.... all without external dependencies.Proposed Work
pkg/orinternal/usinglog/slog.log.Printf/fmt.Printflogging calls withslog.Info,slog.Debug,slog.Erroracross:pkg/unikontainers/(VM lifecycle, network, initrd)pkg/containerd-shim/(shim operations)cmd/urunc/(CLI commands)--log-formatflag touruncCLI supportingtext(default) andjson.--log-levelflag supportingdebug,info,warn,error.Why This Matters
runc,containerdboth use structured logging).slogis in the standard library.Acceptance Criteria
sloglogger is initialized at program startup with configurable level/format.urunc --log-level=debug --log-format=jsonproduces valid JSON logs.Non-Priorities
slogonly.I can start with
pkg/unikontainers/and then move on from there...