Repository navigation
Rotate the audit log by size (#161) - #163
Merged
Merged
Conversation
audit.log moves to audit.log.1 before a line would pass audit.maxBytes (default 10MB), older files up by one, none kept past audit.keep (default 10; 0 keeps all, maxBytes 0 never rotates). A line is never split. read() goes newest file first, each from its end in blocks, and stops at the limit or since, instead of reading the whole log per request. Also fixes since: times have 3, 6 or 9 fraction digits, so comparing them as text could end the list too early; they compare as instants now, and a partly typed time is the start of that period. Closes #161 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #161.
Rotation:
audit.logpastaudit.maxBytes(default10MB; KB, MB and GB accepted), the file moves toaudit.log.1and the older ones move up by one.audit.keep(default 10) are deleted, so the log takes at most about 110 MB.audit.keep=0deletes nothing;audit.maxBytes=0never rotates (the old behaviour).audit.keep: the extra files go at the next rotation.audit.logis rotated on the first line written after the upgrade. Nothing is deleted at that point.Reading:
Audit.read()(the Audit view,GET /api/audit) now goes newest file first, reading each file backwards from its end in 64 KB blocks. It stops atlimitorsince. Before, it read the whole log withreadAllLineson every request.Fixed along the way: the
sincefilter compared times as text.Instant.toString()writes 3, 6 or 9 fraction digits, so.123456Zsorted before.1234Z, which could end the list too early. The new concurrent-writers test caught it.2026-10-07or2026-10-07T09:30now means the start of that period, in UTC. The box's placeholder says UTC.Docs:
audit.keep=0if nothing may be deleted.Tests:
AuditTest(8 tests):keep(including 0, and lowering it later);maxBytes=0;sincevalues;bin/smoke-hosted.shruns the server withaudit.maxBytes=2KBandaudit.keep=0:/api/auditreads past the current file;mvn packageandbin/smoke.shpass;bin/smoke-hosted.shpasses with the new checks.🤖 Generated with Claude Code