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

should use fwrite not fputs #180

Closed
weissi opened this issue Feb 22, 2021 · 2 comments
Closed

should use fwrite not fputs #180

weissi opened this issue Feb 22, 2021 · 2 comments
Labels
good first issue Good for newcomers
Milestone

Comments

@weissi
Copy link
Member

weissi commented Feb 22, 2021

_ = fputs(ptr, self.file)

We should use fwrite and not fputs here... Usually doesn't matter unless we print a 0 byte which could be a hard to debug thing if we lose everything after the 0 byte with fputs.

@weissi weissi added the good first issue Good for newcomers label Feb 22, 2021
@ktoso ktoso added this to the 1.4.2 milestone Feb 23, 2021
@ktoso ktoso modified the milestones: 1.4.2, 1.4.3 Mar 4, 2021
felipejinli added a commit to felipejinli/swift-log that referenced this issue Apr 4, 2021
felipejinli added a commit to felipejinli/swift-log that referenced this issue Apr 4, 2021
felipejinli added a commit to felipejinli/swift-log that referenced this issue Apr 6, 2021
felipejinli added a commit to felipejinli/swift-log that referenced this issue Apr 6, 2021
felipejinli added a commit to felipejinli/swift-log that referenced this issue Apr 6, 2021
weissi added a commit that referenced this issue Apr 6, 2021
Replaced `fputs` with `fwrite`, added test and made spelling corrections

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 to `fwrite`.   Added helper internal func `contiguousUTF8(_ string: String) -> String.UTF8View`. Added `testStdioOutputStreamWrite()` to test ability to log content after 0 byte.

Result:

Improved debugging experience

Co-authored-by: Johannes Weiss <[email protected]>
@weissi
Copy link
Member Author

weissi commented Apr 6, 2021

fixed by #188

@himanshu007-creator
Copy link

Please close this issue

@weissi weissi closed this as completed Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants