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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove stack-specific unicode logic from RIO.Prelude.Logger #73

Closed

Conversation

mgsloan
Copy link
Contributor

@mgsloan mgsloan commented Mar 20, 2018

It seems like this should be done differently in stack anyway, directly munging particular process output instead of applying to all of stack's logging.

let text'
| unicode = text
| otherwise = T.map replaceUnicode text
TIO.hPutStr handle' text'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This branch is definitely not Stack specific. In the new version of the code, you seem to be ignoring the logUseUtf8 value entirely. This code will not work on any machine with a locale/code page setting that does not support UTF-8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you take a look at the replaceUnicode function, it only replaces two codepoints specific to GHC output.

Yes, logUseUtf8 is ignored entirely, it's intended to be read by the user. On further review, that is probably unexpected and probably should have an accompanying askUseUtf8 or something.

So, what should we do here? There are a few different ways to munge unicode into 7 bit ASCII

Copy link
Contributor Author

@mgsloan mgsloan Mar 20, 2018

Choose a reason for hiding this comment

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

Do other loggers just punt on this? Why is it particularly coming up here? Just that stack has been used in a larger variety of environments?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you're missing the exact line of code that I'm commenting on. The way the code works today is that, if the file handle doesn't support UTF8, we decode the bytestring to Text and then use the textual I/O functions to output it.

Copy link
Contributor Author

@mgsloan mgsloan Mar 23, 2018

Choose a reason for hiding this comment

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

I see. I'm not familiar with how hPutBuilder handle' (builder <> flush) would differ from T.hPutStrLn (decodeUtf8 ...). Seems like it should be pretty equivalent (assuming it parses as utf8).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I guess it's because in theory it will work for things that aren't utf-8. Having a hard time finding where in the code that happens, though. I guess the stuff in System.IO does that. It looks like the text io stuff will have different concurrent behavior, potentially interspersing output of chars.

@mgsloan mgsloan mentioned this pull request Mar 20, 2018
4 tasks
@snoyberg
Copy link
Collaborator

snoyberg commented Apr 3, 2018

Discussed offline. The code is not Stack specific, and needs to remain. There's an argument to be made around the quote replacement, but overall it does good without major harm (just a single traversal of a Text), so leaving.

@snoyberg snoyberg closed this Apr 3, 2018
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.

2 participants