Keep debug logging out of the terminal; fresh log every launch - #14
Merged
Merged
Conversation
debug_log wrote every line to debug.log and also printed it to stderr. Lines printed while the world loaded sat behind the game screen, and they (plus the teardown lines) were left in the terminal when the player quit. The log panel (L) already shows them from the file, so debug_log now writes the file only. main.py already emptied debug.log on each launch (keeping the previous session as combat.log), but only after the game modules were imported, and some of them log while importing, so each session lost its first lines. rotate_logs() now runs before those imports and uses the configured DEBUG_LOG_FILE instead of a hard-coded name. 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.
When you quit, the terminal showed the debug lines from world loading (and teardown).
debug_logprinted every line to the terminal as well asdebug.log; the ones printed before the game screen opened were left in scrollback.debug_lognow writesdebug.logonly. The log panel (L) still shows everything. Real startup failures ("Could not load game data") still print, since there is no screen yet to show them.debug.logand keeps the previous session ascombat.log, but the reset now runs before the game modules import. Before, the lines they log while importing (e.g. the combat system's attack table) were wiped from every session. It also uses the configuredDEBUG_LOG_FILEinstead of a hard-coded name.Checked with a simulated launch in a scratch copy (real
main.py, headless UI in place of the screen): nothing printed to the terminal, the old log moved tocombat.log, and the newdebug.logincludes the import-time lines.make check: ruff and mypy clean, 409 passed (4 new intests/test_logging.py), content validates.🤖 Generated with Claude Code