sd-journal: when formatting log messages, implicitly strip trailing whitespace
authorLennart Poettering <lennart@poettering.net>
Fri, 1 Jul 2016 00:37:21 +0000 (17:37 -0700)
committerLennart Poettering <lennart@poettering.net>
Tue, 19 Jul 2016 12:21:49 +0000 (14:21 +0200)
commitc24f1f9df1a79f413dc1cdad27341027e58d2a1f
treeec925610539845afd5efcd4e603b52fcd12e89b3
parentbb557f90f842fb9646a83fd3c21ba359bb8c0f28
sd-journal: when formatting log messages, implicitly strip trailing whitespace

When converting log messages from human readable text into binary records to
send off to journald in sd_journal_print(), strip trailing whitespace in the
log message. This way, handling of logs made via syslog(), stdout/stderr and
sd_journal_print() are treated the same way: trailing (but not leading)
whitespace is automatically removed, in particular \n and \r. Note that in case
of syslog() and stdout/stderr based logging the stripping takes place
server-side though, while for the native protocol based transport this takes
place client-side. This is because in the former cases conversion from
free-form human-readable strings into structured, binary log records takes
place on the server-side while for journal-native logging it happens on the
client side, and after conversion into binary records we probably shouldn't
alter the data anymore.

See: #3416
src/journal/journal-send.c