feat(log): implement structured logging with rotation #105
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/kronai!105
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/0051-implement-logging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Implement a comprehensive logging system: JSON structured logging, configurable log levels, rotating file handler, and CLI integration.
Why
Production-ready logging for debugging, monitoring, and log management.
Testing
Breaking Changes
None.
Notes
New config fields:
json_logs,log_max_bytes,log_backup_count. Newsrc/kronai/log.pymodule withJSONFormatterandsetup_logging().Closes #0048
Closes #0049
Closes #0050
Closes #0051
Automated Review — PR #105
Result: APPROVED
Clean logging implementation. JSON formatter, rotating file handler, configurable levels, and CLI integration all work well.
JSONFormattercorrectly serializes log records (timestamp, level, logger, message, exception).setup_loggingconfigures console + file handlers, clears stale handlers on reconfig. Rotating file handler with configurable sizes.setup_loggingis defensive.JSONFormatterextendslogging.Formatteras expected.Suggestions (non-blocking)
src/kronai/cli.py:113-115—main()callsload_config()to get log settings, then subcommands (_cmd_list,_cmd_run) call it again. Config is loaded twice every command. Consider passing the loaded config to subcommands.src/kronai/log.py:32— JSON timestamp format%Y-%m-%dT%H:%M:%Slacks timezone info. Consider using UTC (time.gmtime) and appendingZfor unambiguous timestamps.tests/unit/test_log.py:85-97—test_json_format_produces_valid_jsonmanually clears root handlers and adds a StringIO handler. This is fragile — if run after othersetup_loggingtests, state leakage could occur. Consider using pytest'scaplogfixture or isolating via a logger hierarchy (child loggers) instead of the root.