domains / orchestration / apple/container
Use structured logger consistently
Adopt a single logging approach across commands and services: - **Never use `print`/direct `FileHandle.standardError.write` in production code** for user-facing or diagnostic messages. Use `Logger`.
Adopt a single logging approach across commands and services:
- Never use
print/directFileHandle.standardError.writein production code for user-facing or diagnostic messages. UseLogger. - Plumb and reuse the existing logger:
- In
AsyncLoggableCommand, use the providedlog—don’t create a redundant logger. - In utilities/helpers, accept a
log: Logger(orlog: Logger?when optional) from the caller; don’t do unconditional stderr output inside the helper.
- In
- Use structured logging: prefer
metadatadictionaries over interpolating values into the message.- Example pattern:
log.warning( "failed to load container", metadata: ["path": dir.path, "error": String(describing: error)] )
- Example pattern:
- Choose appropriate levels for stderr/normal flows: avoid logging non-error conditions to stderr; reserve
warning/errorfor actionable issues, and usedebug/tracefor noisy entry/exit or busy calls. - Keep test diagnostics real: when cleanup fails, log enough details to diagnose (name, error, stdout/stderr/status) rather than retrying in a way that hides the root cause.
Applying this consistently will keep stderr output clean, make logs machine-parseable, and ensure logging behavior follows configured verbosity (e.g., --debug should increase log level via the logger/handler, not by adding new ad-hoc prints).