mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-04-23 14:58:14 +02:00
Make default handling more natural for modern logs, especially JSON lines. This aligns with common expectations of line-separated records and reduces surprises when viewing files with standard tools. Impact: Default changes; messages without trailing LF now get one added. Backward-compatibility: We accept this change because the common and portable convention is LF-terminated records. Most users expect this, and many tools assume it. The risk is limited to consumers that require byte-identical output without a final LF. Those users can restore the old behavior by setting addLF="off" globally or per action. There was also some clean-up of variable names and the removal of accidentally included obsolete-legacy style config directive. Previously, omfile wrote rendered messages as-is unless addLF was set. This could yield "incomplete lines" when templates did not terminate with LF. We now default addLF to on and only append when the message does not already end with LF, preserving existing full-line writes. The change is implemented by making the instance default true; module- and action-level settings continue to override. Behavior remains transparent with compression and crypto providers; no ABI/API impact. Before: messages lacking LF were written without a final newline. After: such messages are written with a single LF appended.
29 lines
892 B
Bash
Executable File
29 lines
892 B
Bash
Executable File
#!/bin/bash
|
|
# addd 2016-07-11 by RGerhards, released under ASL 2.0
|
|
. ${srcdir:=.}/diag.sh init
|
|
setvar_RS_HOSTNAME
|
|
generate_conf
|
|
add_conf '
|
|
module(load="../plugins/imtcp/.libs/imtcp")
|
|
input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port")
|
|
template(name="outfmt" type="string" string="%hostname%") # no LF, as HOSTNAME file also does not have it!
|
|
|
|
local4.debug action(type="omfile" template="outfmt" file=`echo $RSYSLOG_OUT_LOG` addLF="off")
|
|
'
|
|
startup
|
|
echo '<167>Mar 6 16:57:54 hostname1/hostname2 test: msgnum:0' > $RSYSLOG_DYNNAME.input
|
|
tcpflood -B -I $RSYSLOG_DYNNAME.input
|
|
shutdown_when_empty
|
|
wait_shutdown
|
|
printf '%s' "$RS_HOSTNAME" | cmp - $RSYSLOG_OUT_LOG
|
|
if [ ! $? -eq 0 ]; then
|
|
echo "invalid hostname generated, $RSYSLOG_OUT_LOG is:"
|
|
cat $RSYSLOG_OUT_LOG
|
|
echo
|
|
echo "expected was:"
|
|
printf '%s\n' "$RS_HOSTNAME"
|
|
echo
|
|
error_exit 1
|
|
fi;
|
|
exit_test
|