From 205defb597295a4a8966db3e618cfe41a29bed99 Mon Sep 17 00:00:00 2001 From: Giovanni Giacobbi Date: Tue, 27 Jul 2021 15:15:26 +0200 Subject: [PATCH] logread: fix erroneous message "Logread connected to" with udp When streaming the syslog messages via udp, the socket connection always succeeds by definition, but it can still fail to send. In such case, the syslog keep repeating the following two messages: failed to send log data to ip:port via udp Logread connected to ip:port With this change, only one initial message "Logread connected to..." is logged. Also fixed capital letter for "failed to send" message. Signed-off-by: Giovanni Giacobbi Signed-off-by: Daniel Golle (string de-duplication) --- log/logread.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/log/logread.c b/log/logread.c index a764742..f48dd4b 100644 --- a/log/logread.c +++ b/log/logread.c @@ -97,7 +97,13 @@ static void log_handle_reconnect(struct uloop_timeout *timeout) uloop_timeout_set(&retry, 1000); } else { uloop_fd_add(&sender, ULOOP_READ); - syslog(LOG_INFO, "Logread connected to %s:%s\n", log_ip, log_port); + + if (log_udp < 2) + syslog(LOG_INFO, "Logread connected to %s:%s via %s\n", + log_ip, log_port, (log_udp) ? ("udp") : ("tcp")); + + if (log_udp == 1) + ++log_udp; } } @@ -192,7 +198,7 @@ static int log_notify(struct blob_attr *msg) } if (err < 0) { - syslog(LOG_INFO, "failed to send log data to %s:%s via %s\n", + syslog(LOG_INFO, "Failed to send log data to %s:%s via %s\n", log_ip, log_port, (log_udp) ? ("udp") : ("tcp")); uloop_fd_delete(&sender); close(sender.fd); -- 2.30.2