logread: fix erroneous message "Logread connected to" with udp
authorGiovanni Giacobbi <giovanni@giacobbi.net>
Tue, 27 Jul 2021 13:15:26 +0000 (15:15 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 3 Aug 2021 21:02:36 +0000 (22:02 +0100)
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 <giovanni@giacobbi.net>
Signed-off-by: Daniel Golle <daniel@makrotopia.org> (string de-duplication)
log/logread.c

index a7647421e95d2774332ce5d9de91756b5657faf9..f48dd4bb6ae0ad436702b09dfee4371a004e2217 100644 (file)
@@ -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);