syslog: use appropriate levels for logging
[project/ubox.git] / log / logread.c
index 28c9462904e69e07ae1649fa6ae9658567d320b6..871cd5bffe9a855209a45e50f4ccad20dd0dadec 100644 (file)
@@ -79,7 +79,7 @@ static void log_handle_reconnect(struct uloop_timeout *timeout)
                uloop_timeout_set(&retry, 1000);
        } else {
                uloop_fd_add(&sender, ULOOP_READ);
-               syslog(0, "Logread connected to %s:%s\n", log_ip, log_port);
+               syslog(LOG_INFO, "Logread connected to %s:%s\n", log_ip, log_port);
        }
 }
 
@@ -135,9 +135,12 @@ static int log_notify(struct blob_attr *msg)
        if (log_type == LOG_NET) {
                int err;
 
-               *buf = '\0';
-               if (hostname)
-                       snprintf(buf, sizeof(buf), "%s ", hostname);
+               snprintf(buf, sizeof(buf), "<%u>", p);
+               strncat(buf, c + 4, 16);
+               if (hostname) {
+                       strncat(buf, hostname, sizeof(buf));
+                       strncat(buf, " ", sizeof(buf));
+               }
                if (log_prefix) {
                        strncat(buf, log_prefix, sizeof(buf));
                        strncat(buf, ": ", sizeof(buf));
@@ -151,7 +154,7 @@ static int log_notify(struct blob_attr *msg)
                        err = send(sender.fd, buf, strlen(buf), 0);
 
                if (err < 0) {
-                       syslog(0, "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);