New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid mutating global STDOUT & STDERR #1837
Conversation
I'm afraid I don't understand the use case. This PR mostly changes how our internal logs interact with flush. This seems weird, first of all, because the whole point of I also don't understand the PR title - how was global stdout and stderr being modified before this PR? |
This call results in setting In the current code path, whenever I would like to prevent this side effect, so Puma applications can run with I'm unfamiliar with the reasoning behind the current code setting |
Why not just change the default IO to a new STDOUT/STDERR object, then? E.g. def self.stdio
Events.new $stdout.dup, $stderr.dup
end |
That leaves the separate issue of us forcing you to use sync = true, but at least we avoid the global side effect. |
Actually, even better: def self.stdio
stdout = $stdout.dup
stdout.sync = false
stderr = $stderr.dup
stderr.sync = false
Events.new stdout, stderr
end then rm the sync code from Events#initialize |
@nateberkopec To catch |
I think that's OK, but you'll need to make sure that the rack handler changes it's arguments so that the correct item is used. |
Not sure I follow, are you worried about the resulting |
On that line, |
Sorry if I'm still missing something, but I thought that's what my change would address. By
|
Well, write a test and we'll find out then 😆 You'll have to fix the tests that are looking for output at $stdout/$stderr too unfortunately. |
Looking at this again and I think you're probably write, but it does need new tests + fixes of the old ones for a merge. |
Thanks for all your work @montanalow ! |
This reverts commit 70b28bb.
This reverts commit 70b28bb.
This reverts commit 70b28bb.
Who could have guessed the entire Puma logging ecosystem somehow depended on us modifying STDOUT.sync to true... a good lesson for software maintainership - modifying a global is probably worth a major version bump! |
This reverts commit 70b28bb.
The current behavior prevents apps from benefitting from
STDOUT.sync = false
during configuration phases, since the initial call toEvent.stdio
is relatively late in the boot cycle.