Repository navigation
Per-session log files with size rollover (#291) - #1108
Open
IcanBENCHurCAT wants to merge 2 commits into
Open
IcanBENCHurCAT wants to merge 2 commits into
IcanBENCHurCAT wants to merge 2 commits into
Conversation
The file sink stopped recording once log.txt hit its 50 MB limit. Give each session its own timestamped log file, roll on size within a session, and prune old sessions on startup keeping the last 10. Grouping and pruning logic lives in C7Engine (LogFiles) so it is unit tested; no new packages.
WritableDir is empty in editor runs, so LogFilePath is a bare filename and Path.GetDirectoryName returns an empty string, which PruneOldSessions treats as no directory and skips. Old session logs were never pruned in those runs (exported builds were unaffected). Resolve the full path before taking the directory, which matches where the sink writes the relative path.
Author
|
found a bug in this one while testing on windows with a real godot launch: old sessions never got pruned when running from the editor. WritableDir is empty there, so LogFilePath is a bare filename, GetDirectoryName returns an empty string, and PruneOldSessions reads that as no directory and bails. exported builds were fine and the unit tests were fine (they pass a real directory), only an actual launch caught it. fix is in 8ddf2fc: resolve the full path before taking the directory in LogManager, so pruning sees the directory the sink actually writes to. one line plus a comment saying why. |
Member
|
That all sounds reasonable to me. I'm still surprised none of this was baked into Serilog. |
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 #291
following up on the discussion in #291. the file sink stops recording once log.txt hits the 50 MB limit, and as i found digging into it there, stock serilog rolling does not fix the naming either (the plain filename ends up being the oldest chunk, not the latest).
this takes the per-session route wildweazel leaned toward:
the grouping/pruning logic lives in C7Engine as LogFiles (pure System.IO) so it can be unit tested, C7 itself is not referenced by EngineTests. LogFilesTest covers the filename format, session grouping including rolled chunks and the legacy files, and the prune rules.
one judgement call in there: FilesPerSessionToKeep is 10, so a single session caps around 500 MB. the sink default would have been 31 chunks, close to 1.5 GB, which felt like a lot. easy to change if you want a different number.