From ee36266a55478672ad2c5f4efbd6ca0bef3d37cd Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 6 Aug 2024 14:07:37 +0200 Subject: log, passt: Keep printing to stderr when passt is running in foreground There are two cases where we want to stop printing to stderr: if it's closed, and if pasta spawned a shell (and --debug wasn't given). But if passt is running in foreground, we currently stop to report any message, even error messages, once we're ready, as reported by Laurent, because we set the log_runtime flag, which we use to indicate we're ready, regardless of whether we're running in foreground or not. Turn that flag (back) to log_stderr, and set it only when we really want to stop printing to stderr. Reported-by: Laurent Vivier Fixes: afd9cdc9bb48 ("log, passt: Always print to stderr before initialisation is complete") Signed-off-by: Stefano Brivio --- log.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'log.c') diff --git a/log.c b/log.c index eb3a780..4ecc2ad 100644 --- a/log.c +++ b/log.c @@ -44,7 +44,7 @@ struct timespec log_start; /* Start timestamp */ int log_trace; /* --trace mode enabled */ bool log_conf_parsed; /* Logging options already parsed */ -bool log_runtime; /* Daemonised, or ready in foreground */ +bool log_stderr = true; /* Not daemonised, no shell spawned */ /** * logtime_fmt_and_arg() - Build format and arguments to print relative log time @@ -257,7 +257,7 @@ void vlogmsg(bool newline, int pri, const char *format, va_list ap) } if (debug_print || !log_conf_parsed || - (!log_runtime && (log_mask & LOG_MASK(LOG_PRI(pri))))) { + (log_stderr && (log_mask & LOG_MASK(LOG_PRI(pri))))) { (void)vfprintf(stderr, format, ap); if (newline && format[strlen(format)] != '\n') fprintf(stderr, "\n"); @@ -364,7 +364,7 @@ void passt_vsyslog(bool newline, int pri, const char *format, va_list ap) if (newline && format[strlen(format)] != '\n') n += snprintf(buf + n, BUFSIZ - n, "\n"); - if (log_sock >= 0 && send(log_sock, buf, n, 0) != n && !log_runtime) + if (log_sock >= 0 && send(log_sock, buf, n, 0) != n && log_stderr) fprintf(stderr, "Failed to send %i bytes to syslog\n", n); } -- cgit v1.2.3