RFC 5424 specifies that an empty APP-NAME needs to be indicated by
"-". Instead, the field could become empty under certain conditions.
If so, outgoing 5424 messages were invalidly formatted.
This happened under quite unusual conditions, but could be seen
in practice.
This commit also does some very light non-related code improvement
and also includes the testbench test to check the fixed error condition.
closes https://github.com/rsyslog/rsyslog/issues/4043