[v3,00/14] Detect superfluous newline in logs

Message ID 20231218092738.749604-1-david.marchand@redhat.com (mailing list archive)
Headers
Series Detect superfluous newline in logs |

Message

David Marchand Dec. 18, 2023, 9:27 a.m. UTC
  Getting readable and consistent logs is important when running a DPDK
application, especially when troubleshooting.
A common issue with logs is when a DPDK change do not add (or on the
contrary add too many \n) in the format string.

This issue would only get noticed when actually hitting this log (which
may be a situation hard to reach).

This series proposes to introduce a new RTE_LOG_LINE helper that is
responsible for logging a one line message and spews a build error (with
gcc) if any \n is part of the format string.


Because this is still a RFC and a lot of changes are added in this v2, no ack
from the v1 has been kept.

Since the v1 discussion on the cover letter, I changed my mind, and made the
choice to break existing logging helpers exported in the public API.
The reasoning is that those should not be used in the first place:
logs should be produced only by the library that registers the logtype.

Some multiline logging for debugging and the test assert macros are
still present, but in this case an explicit call to RTE_LOG() is done.
This can be checked with a simple:
$ git grep 'RTE_LOG(' -- lib/ :^lib/log/
lib/acl/acl_bld.c:      RTE_LOG(DEBUG, ACL, "Build phase for ACL \"%s\":\n"
lib/acl/acl_gen.c:      RTE_LOG(DEBUG, ACL, "Gen phase for ACL \"%s\":\n"
lib/bpf/bpf_validate.c: RTE_LOG(DEBUG, BPF, "%s(%p) stats:\n"
lib/bpf/bpf_validate.c: RTE_LOG(DEBUG, BPF,
lib/eal/common/eal_common_debug.c:              RTE_LOG(CRIT, EAL, "Error - exiting with code: %d\n"
lib/eal/include/rte_test.h:             RTE_LOG(ERR, EAL, "Test assert %s line %d failed: "           \
lib/ip_frag/ip_frag_common.h:#define    IP_FRAG_LOG(lvl, fmt, args...)  RTE_LOG(lvl, IPFRAG, fmt, ##args)
lib/sched/rte_sched.c:  RTE_LOG(DEBUG, SCHED, "Low level config for pipe profile %u:\n"
lib/sched/rte_sched.c:  RTE_LOG(DEBUG, SCHED, "Low level config for subport profile %u:\n"


Changes since RFC v2:
- sent as non RFC,
- fixed format string crossing line boundaries,
- avoided potential collision with BPF_ namespace,

Changes since RFC v1:
- rebased after Stephen log changes,
- added more fixes as I was making progress on the topic,
- added a check so dpdk developers stop using RTE_LOG(),
- added preparation patches, like "lib: replace logging helpers",
- converted all libraries, keeping some special cases with explicit
  calls to RTE_LOG,