-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
improve handling of trailing newline in journal logging #3636
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
c24f1f9
8980058
4c5db93
0d23bc5
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 |
|---|---|---|
|
|
@@ -107,6 +107,13 @@ _public_ int sd_journal_printv(int priority, const char *format, va_list ap) { | |
| memcpy(buffer, "MESSAGE=", 8); | ||
| vsnprintf(buffer+8, sizeof(buffer) - 8, format, ap); | ||
|
|
||
| /* Strip trailing whitespace, keep prefix whitespace. */ | ||
| (void) strstrip(buffer); | ||
|
|
||
| /* Suppress empty lines */ | ||
| if (isempty(buffer+8)) | ||
| return 0; | ||
|
|
||
| zero(iov); | ||
| IOVEC_SET_STRING(iov[0], buffer); | ||
| IOVEC_SET_STRING(iov[1], p); | ||
|
|
@@ -158,6 +165,8 @@ _printf_(1, 0) static int fill_iovec_sprintf(const char *format, va_list ap, int | |
|
|
||
| VA_FORMAT_ADVANCE(format, ap); | ||
|
|
||
| (void) strstrip(buffer); /* strip trailing whitespace, keep prefixing whitespace */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we shouldn't change the behaviour of the instead of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, maybe, this is ok. |
||
|
|
||
| IOVEC_SET_STRING(iov[i++], buffer); | ||
|
|
||
| format = va_arg(ap, char *); | ||
|
|
@@ -471,6 +480,13 @@ _public_ int sd_journal_printv_with_location(int priority, const char *file, con | |
| memcpy(buffer, "MESSAGE=", 8); | ||
| vsnprintf(buffer+8, sizeof(buffer) - 8, format, ap); | ||
|
|
||
| /* Strip trailing whitespace, keep prefixing whitespace */ | ||
| (void) strstrip(buffer); | ||
|
|
||
| /* Suppress empty lines */ | ||
| if (isempty(buffer+8)) | ||
| return 0; | ||
|
|
||
| /* func is initialized from __func__ which is not a macro, but | ||
| * a static const char[], hence cannot easily be prefixed with | ||
| * CODE_FUNC=, hence let's do it manually here. */ | ||
|
|
||
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.
shouldn't we document this?
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.
yes, we should. will do.