Description
The current logging implementation in acr-cli relies on fmt.Printf, which lacks structure and flexibility for log management and analysis, not to mention it is locking and thus not great for concurrent use. To improve observability, maintainability, and performance we should use a structured logging. Being most familiar with it and with it being the current most performant go logger, I propose we move to use zerolog https://github.com/rs/zerolog which provides a fast and efficient structured logging library for Go which also provides customizable pretty printing.
Proposed Changes
-
Replace fmt.Printf with zerolog
- Introduce
zerolog as the primary logging mechanism.
- Ensure all existing log statements are migrated to structured logs.
-
Add a --log-level flag
- Allow users to configure the verbosity of logs (
debug, info, warn, error).
- Default to
info level if not specified.
-
Add a --log-format flag
- Allow users to choose between
json and console (human-readable) output formats.
- Default to
console for CLI usability, but support json for integration with log aggregation tools.
-
Enhance Logging for Manifest Purge Logic
- Add detailed logs to indicate:
- Why a manifest is being excluded from purging (Info)
- What criteria were evaluated (Debug)
- Skipped actions due to errors e.g 404 (Warn)
Benefits
- Improved debugging and traceability
- Improved performance due to better logging
Tasks
Description
The current logging implementation in acr-cli relies on fmt.Printf, which lacks structure and flexibility for log management and analysis, not to mention it is locking and thus not great for concurrent use. To improve observability, maintainability, and performance we should use a structured logging. Being most familiar with it and with it being the current most performant go logger, I propose we move to use zerolog https://github.com/rs/zerolog which provides a fast and efficient structured logging library for Go which also provides customizable pretty printing.
Proposed Changes
Replace
fmt.Printfwithzerologzerologas the primary logging mechanism.Add a
--log-levelflagdebug,info,warn,error).infolevel if not specified.Add a
--log-formatflagjsonandconsole(human-readable) output formats.consolefor CLI usability, but supportjsonfor integration with log aggregation tools.Enhance Logging for Manifest Purge Logic
Benefits
Tasks
zerologdependency.fmt.Printfcalls to use structured logging.