diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2024-08-12 10:20:34 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-08-12 16:21:53 +0200 |
commit | fecb1b65b1ac4d95f6a3bd5b09c189119ecf46b9 (patch) | |
tree | 80e21cdf36dae4dfe28de9b3e46886935fcfcdec /log.h | |
parent | baccfb95ce0e30f64d052f710cd5fedc8c7426c1 (diff) | |
download | passt-fecb1b65b1ac4d95f6a3bd5b09c189119ecf46b9.tar passt-fecb1b65b1ac4d95f6a3bd5b09c189119ecf46b9.tar.gz passt-fecb1b65b1ac4d95f6a3bd5b09c189119ecf46b9.tar.bz2 passt-fecb1b65b1ac4d95f6a3bd5b09c189119ecf46b9.tar.lz passt-fecb1b65b1ac4d95f6a3bd5b09c189119ecf46b9.tar.xz passt-fecb1b65b1ac4d95f6a3bd5b09c189119ecf46b9.tar.zst passt-fecb1b65b1ac4d95f6a3bd5b09c189119ecf46b9.zip |
log: Don't prefix message with timestamp on --debug if it's a continuation
If we prefix the second part of messages printed through
logmsg_perror() by the timestamp, on debug, we'll have two timestamps
and a weird separator in the result, such as this beauty:
0.0013: Failed to clone process with detached namespaces0.0013: : Operation not permitted
Add a parameter to logmsg() and vlogmsg() which indicates a message
continuation. If that's set, don't print the timestamp in vlogmsg().
Link: https://github.com/moby/moby/issues/48257#issuecomment-2282875092
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'log.h')
-rw-r--r-- | log.h | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -13,21 +13,21 @@ #define LOGFILE_CUT_RATIO 30 /* When full, cut ~30% size */ #define LOGFILE_SIZE_MIN (5UL * MAX(BUFSIZ, PAGE_SIZE)) -void vlogmsg(bool newline, int pri, const char *format, va_list ap); -void logmsg(bool newline, int pri, const char *format, ...) - __attribute__((format(printf, 3, 4))); +void vlogmsg(bool newline, bool cont, int pri, const char *format, va_list ap); +void logmsg(bool newline, bool cont, int pri, const char *format, ...) + __attribute__((format(printf, 4, 5))); void logmsg_perror(int pri, const char *format, ...) __attribute__((format(printf, 2, 3))); -#define err(...) logmsg(true, LOG_ERR, __VA_ARGS__) -#define warn(...) logmsg(true, LOG_WARNING, __VA_ARGS__) -#define info(...) logmsg(true, LOG_INFO, __VA_ARGS__) -#define debug(...) logmsg(true, LOG_DEBUG, __VA_ARGS__) +#define err(...) logmsg(true, false, LOG_ERR, __VA_ARGS__) +#define warn(...) logmsg(true, false, LOG_WARNING, __VA_ARGS__) +#define info(...) logmsg(true, false, LOG_INFO, __VA_ARGS__) +#define debug(...) logmsg(true, false, LOG_DEBUG, __VA_ARGS__) -#define err_perror(...) logmsg_perror( LOG_ERR, __VA_ARGS__) -#define warn_perror(...) logmsg_perror( LOG_WARNING, __VA_ARGS__) -#define info_perror(...) logmsg_perror( LOG_INFO, __VA_ARGS__) -#define debug_perror(...) logmsg_perror( LOG_DEBUG, __VA_ARGS__) +#define err_perror(...) logmsg_perror( LOG_ERR, __VA_ARGS__) +#define warn_perror(...) logmsg_perror( LOG_WARNING, __VA_ARGS__) +#define info_perror(...) logmsg_perror( LOG_INFO, __VA_ARGS__) +#define debug_perror(...) logmsg_perror( LOG_DEBUG, __VA_ARGS__) #define die(...) \ do { \ |