1
0
Fork 0
mirror of https://passt.top/passt synced 2025-06-07 16:35:33 +02:00

log: Drop newlines in the middle of the perror()-like messages

Calling vlogmsg() twice from logmsg_perror() results in this beauty:

  $ ./pasta -i foo
  Invalid interface name foo
  : No such device

because the first part of the message, corresponding to the first
call, doesn't end with a newline, and vlogmsg() adds it.

Given that we can't easily append an argument (error description) to
a variadic list, add a 'newline' parameter to all the functions that
currently add a newline if missing, and disable that on the first call
to vlogmsg() from logmsg_perror(). Not very pretty but I can't think
of any solution that's less messy than this.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Stefano Brivio 2024-07-24 16:36:17 +02:00
parent 13295583f8
commit 1cd773081f
3 changed files with 32 additions and 22 deletions

2
flow.c
View file

@ -279,7 +279,7 @@ void flow_log_(const struct flow_common *f, int pri, const char *fmt, ...)
else
type_or_state = FLOW_TYPE(f);
logmsg(pri, "Flow %u (%s): %s", flow_idx(f), type_or_state, msg);
logmsg(true, pri, "Flow %u (%s): %s", flow_idx(f), type_or_state, msg);
}
/**