[$25 BOUNTY] [C] Add frailbox logger rotation retention report#23
Open
leo202000 wants to merge 2 commits into
Open
[$25 BOUNTY] [C] Add frailbox logger rotation retention report#23leo202000 wants to merge 2 commits into
leo202000 wants to merge 2 commits into
Conversation
- Add log_rotation_report() API to logger.h: scans *.log files in a directory and produces a retention report with retain/prune decisions based on max_files, max_age_secs, and max_total_bytes policies. - Report entries include filename, size, mtime, decision, and reason. Only file metadata is accessed; raw log content is never read or exposed (verified by tests checking JSON/text output for secrets). - Add log_rotation_report_to_json() and log_rotation_report_to_text() formatters. JSON includes ISO-8601 mtime timestamps. - Add log_rotation_report_free() for cleanup. - Existing logger behavior remains compatible by default (new API is opt-in; no changes to existing log_init/log_message/log_shutdown). - Add frailbox/tests/test_rotation.c: 30 tests covering max_files, max_age, combined policies, no-limits, NULL/error handling, JSON field validation, and secret-leak prevention. - Add test_rotation target to Makefile. - Document retention report usage in docs/OPERATIONS.md. Closes #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an audit-friendly retention report for frailbox logger rotation decisions, as requested in issue #3.
Changes
frailbox/include/logger.h: New rotation retention report API:log_rotation_report()— scans*.logfiles in a directory and produces retain/prune decisions based onmax_files,max_age_secs, andmax_total_bytespolicies.log_rotation_report_to_json()/log_rotation_report_to_text()— formatters with ISO-8601 mtime timestamps.log_rotation_report_free()— cleanup.frailbox/src/logger.c: Implementation of the retention report. Policies applied in order: age → count → total size (oldest pruned first). Entries sorted newest-first.frailbox/tests/test_rotation.c(new): 30 tests covering:max_filespolicy (retain 2 newest, prune 3 oldest)max_agepolicy (prune files older than threshold)frailbox/Makefile: Addedtest_rotationtarget.docs/OPERATIONS.md: Documented retention report usage, policies, and JSON format.Testing
make test_rotation— 30 tests, all pass (WSL Ubuntu, gcc 13.3.0)python3 build.py— diagnostic build log generated and included belowChecklist
diagnostic/build-c68dc00f.logd)Closes #3