public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] passt: Move __setlogmask() calls before output unrelated to configuration
@ 2022-11-08  8:54 Stefano Brivio
  0 siblings, 0 replies; only message in thread
From: Stefano Brivio @ 2022-11-08  8:54 UTC (permalink / raw)
  To: passt-dev

...so that we avoid printing some lines twice because log-level is
still set to LOG_EMERG, as if logging configuration didn't happen
yet.

While at it, note that logging to stderr doesn't really depend on
whether debug mode is enabled or not.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 passt.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/passt.c b/passt.c
index fd703de..7d323c2 100644
--- a/passt.c
+++ b/passt.c
@@ -243,9 +243,16 @@ int main(int argc, char **argv)
 	conf(&c, argc, argv);
 	trace_init(c.trace);
 
-	if (!c.debug && (c.stderr || isatty(fileno(stdout))))
+	if (c.stderr || isatty(fileno(stdout)))
 		__openlog(log_name, LOG_PERROR, LOG_DAEMON);
 
+	if (c.debug)
+		__setlogmask(LOG_UPTO(LOG_DEBUG));
+	else if (c.quiet)
+		__setlogmask(LOG_UPTO(LOG_ERR));
+	else
+		__setlogmask(LOG_UPTO(LOG_INFO));
+
 	quit_fd = pasta_netns_quit_init(&c);
 
 	c.fd_tap = c.fd_tap_listen = -1;
@@ -267,13 +274,6 @@ int main(int argc, char **argv)
 	if (c.ifi6 && !c.no_dhcpv6)
 		dhcpv6_init(&c);
 
-	if (c.debug)
-		__setlogmask(LOG_UPTO(LOG_DEBUG));
-	else if (c.quiet)
-		__setlogmask(LOG_UPTO(LOG_ERR));
-	else
-		__setlogmask(LOG_UPTO(LOG_INFO));
-
 	pcap_init(&c);
 
 	if (!c.foreground) {
-- 
@@ -243,9 +243,16 @@ int main(int argc, char **argv)
 	conf(&c, argc, argv);
 	trace_init(c.trace);
 
-	if (!c.debug && (c.stderr || isatty(fileno(stdout))))
+	if (c.stderr || isatty(fileno(stdout)))
 		__openlog(log_name, LOG_PERROR, LOG_DAEMON);
 
+	if (c.debug)
+		__setlogmask(LOG_UPTO(LOG_DEBUG));
+	else if (c.quiet)
+		__setlogmask(LOG_UPTO(LOG_ERR));
+	else
+		__setlogmask(LOG_UPTO(LOG_INFO));
+
 	quit_fd = pasta_netns_quit_init(&c);
 
 	c.fd_tap = c.fd_tap_listen = -1;
@@ -267,13 +274,6 @@ int main(int argc, char **argv)
 	if (c.ifi6 && !c.no_dhcpv6)
 		dhcpv6_init(&c);
 
-	if (c.debug)
-		__setlogmask(LOG_UPTO(LOG_DEBUG));
-	else if (c.quiet)
-		__setlogmask(LOG_UPTO(LOG_ERR));
-	else
-		__setlogmask(LOG_UPTO(LOG_INFO));
-
 	pcap_init(&c);
 
 	if (!c.foreground) {
-- 
2.35.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-08  8:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08  8:54 [PATCH] passt: Move __setlogmask() calls before output unrelated to configuration Stefano Brivio

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).