-
Notifications
You must be signed in to change notification settings - Fork 301
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
Improve StdioOutputStream with fwrite (#180) #188
Conversation
Can one of the admins verify this patch? |
8 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
@swift-server-bot test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This is pretty much perfect! Just a !
missing, then we can ship this.
d5ef3ba
to
40b4a73
Compare
@weissi Makes sense - I've just incorporated the changes. It should work now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
@swift-server-bot test this please |
Sorry @felipejinli , could you run |
@weissi done! |
@swift-server-bot test this please |
@swift-server-bot test this please |
Replaced
fputs
withfwrite
, added test and made spelling correctionsWIP help
(for reference, see the code changes)
On the testing side, I'm currently using
String(validatingUTF8: <unsafe-mutable-pointer>
to turn a UnsafeMutablePointer into a String. However, this seems to return a string that stops at the first 0 byte E.g. for a "hello\u{0} world" log it outputs hello only. NB. I have checked thatfwrite
correctly logs a message longer than "hello" through count but testing this is hard. @weissi @ktoso Have you got any suggestions?Motivation:
If a 0 byte is logged,
fputs
would not output the content after the 0 byte making it harder to debug (see #180).fwrite
uses a count argument so content after 0 byte can be logged.Modifications:
Replaced
fputs
with the correct call tofwrite
. Added helper internal funccontiguousUTF8(_ string: String) -> String.UTF8View
. AddedtestStdioOutputStreamWrite()
to test ability to log content after 0 byte.Result:
Improved debugging experience