From: Giovanni Giacobbi Date: Tue, 27 Jul 2021 13:15:26 +0000 (+0200) Subject: logread: fix erroneous message "Logread connected to" with udp X-Git-Url: http://git.openwrt.org/source?a=commitdiff_plain;h=205defb597295a4a8966db3e618cfe41a29bed99;p=project%2Fubox.git 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) --- 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);