Migrate to Structured Logging with zerolog and Improve Logging for Manifest Purge Logic
- Dominant language
- Go
- Stars
- 70
- Forks
- 52
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 12
Description
## 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
1. **Replace `fmt.Printf` with `zerolog`**
- Introduce `zerolog` as the primary logging mechanism.
- Ensure all existing log statements are migrated to structured logs.
2. **Add a `--log-level` flag**
- Allow users to configure the verbosity of logs (`debug`, `info`, `warn`, `error`).
- Default to `info` level if not specified.
3. **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.
4. **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
- [ ] Add `zerolog` dependency.
- [ ] Implement centralized logger setup with configurable log level and format.
- [ ] Refactor existing `fmt.Printf` calls to use structured logging.
- [ ] Add detailed logs around manifest purge decision points.
- [ ] Update CLI documentation and usage examples.
Contributor guide
Assessment
This issue has not been assessed yet.