Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log compiler output atomically and only on debug mode #11

Merged
merged 3 commits into from
Nov 2, 2022

Conversation

agu-z
Copy link
Collaborator

@agu-z agu-z commented Nov 2, 2022

Problem

The core compiler uses functions such as putStrLn, putStrFlush, hPutStr, and Text.PrettyPrint.ANSI.Leijen.displayIO to print to stdout and stderr as it compiles, downloads dependencies, displays errors, etc.

Also, the Watchtower.Find module uses print.

Running these functions without a lock can create garbled output, which can have very undesirable consequences, such as having your computer beep at you or open Print dialogs 馃檭

Solution

Use Ext.Common.debug instead of putStrLn (et al), and introduce Ext.Common.withPrintLockIfDebug to wrap calls to Text.PrettyPrint.ANSI.Leijen so that its IO is performed atomically.

Copy link
Collaborator

@supermario supermario left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 馃憤

@agu-z agu-z merged commit b2d9e3e into main Nov 2, 2022
@agu-z agu-z deleted the agu-z/print-atomically branch November 2, 2022 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants