Repository navigation
Log lines are flushed as they are written - #145
Merged
Merged
Conversation
System::platformLog wrote with printf and never flushed. stdout is fully buffered when it is redirected to a file or a pipe, and a window app has no console, so the lines written before a crash or a killed process were lost (an empty log file). Each line is now flushed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Merged. Thanks! |
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.
Problem
System::platformLog(the default used on desktop) writes withprintfand never flushes. When stdout is redirected to a file or a pipe it is fully buffered, and a window app has no console, so the lines written before a crash or a killed process are lost: the log file comes out empty, exactly when it is needed.Fix
Flush stdout after each line. The platforms with their own
platformLogare not touched.Testing
The engine library builds with MSVC (VS 2022, Debug). The empty log was hit while debugging an app whose output was redirected to a file and the process was then stopped; flushing stdout (there via
setvbuf(stdout, nullptr, _IONBF, 0)at startup) kept the lines.🤖 Generated with Claude Code