-
Notifications
You must be signed in to change notification settings - Fork 266
fix: add missing fflush(stdout) to write log message immediately #442
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -85,7 +85,7 @@ int set_socket_rcvbuf(int fd, int size) { | |||||||||||
| * | ||||||||||||
| * @param level Message log level | ||||||||||||
| * @param format printf style format string | ||||||||||||
| * @returns Whatever printf returns | ||||||||||||
| * @return Message length (newline included) | ||||||||||||
| */ | ||||||||||||
| int logger(loglevel_t level, const char *format, ...) { | ||||||||||||
| va_list ap; | ||||||||||||
|
|
@@ -120,7 +120,10 @@ int logger(loglevel_t level, const char *format, ...) { | |||||||||||
| // Automatically add newline if format doesn't end with one | ||||||||||||
| if (format && strlen(format) > 0 && format[strlen(format) - 1] != '\n') { | ||||||||||||
| fputc('\n', stdout); | ||||||||||||
| r++; | ||||||||||||
|
Comment on lines
122
to
+123
|
||||||||||||
| fputc('\n', stdout); | |
| r++; | |
| if (fputc('\n', stdout) == EOF) { | |
| r = EOF; | |
| } |
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.
The updated docstring claims this function returns the message length (newline included), but the implementation still returns
fputs()'s status code (and potentially modified by later logic). Either adjust the implementation to return the actual number of characters written (based on the renderedmessageand whether a newline was appended), or keep the original semantics and document it as afputs()-style return (non-negative on success, EOF on error).