]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: show accounting data of same type in the same line
authorMike Yuan <me@yhndnzj.com>
Fri, 12 Jan 2024 08:57:13 +0000 (16:57 +0800)
committerMike Yuan <me@yhndnzj.com>
Fri, 12 Jan 2024 08:58:11 +0000 (16:58 +0800)
src/run/run.c

index c78d3c6a1df7f921779c8a00fd4f3f6bee23a6d9..e94ae2abbe68e6ba41c9d12a5fd91b259d6e86c4 100644 (file)
@@ -1822,23 +1822,36 @@ static int start_transient_service(sd_bus *bus) {
                                 log_info("CPU time consumed: %s",
                                          FORMAT_TIMESPAN(DIV_ROUND_UP(c.cpu_usage_nsec, NSEC_PER_USEC), USEC_PER_MSEC));
 
-                        if (c.memory_peak != UINT64_MAX)
-                                log_info("Memory peak: %s", FORMAT_BYTES(c.memory_peak));
+                        if (c.memory_peak != UINT64_MAX) {
+                                const char *swap;
 
-                        if (c.memory_swap_peak != UINT64_MAX)
-                                log_info("Memory swap peak: %s", FORMAT_BYTES(c.memory_swap_peak));
+                                if (c.memory_swap_peak != UINT64_MAX)
+                                        swap = strjoina(" (swap: %s)", FORMAT_BYTES(c.memory_swap_peak));
+                                else
+                                        swap = "";
 
-                        if (c.ip_ingress_bytes != UINT64_MAX)
-                                log_info("IP traffic received: %s", FORMAT_BYTES(c.ip_ingress_bytes));
+                                log_info("Memory peak: %s%s", FORMAT_BYTES(c.memory_peak), swap);
+                        }
 
+                        const char *ip_ingress = NULL, *ip_egress = NULL;
+
+                        if (c.ip_ingress_bytes != UINT64_MAX)
+                                ip_ingress = strjoina(" received: ", FORMAT_BYTES(c.ip_ingress_bytes));
                         if (c.ip_egress_bytes != UINT64_MAX)
-                                log_info("IP traffic sent: %s", FORMAT_BYTES(c.ip_egress_bytes));
+                                ip_egress = strjoina(" sent: ", FORMAT_BYTES(c.ip_egress_bytes));
 
-                        if (c.io_read_bytes != UINT64_MAX)
-                                log_info("IO bytes read: %s", FORMAT_BYTES(c.io_read_bytes));
+                        if (ip_ingress || ip_egress)
+                                log_info("IP traffic%s%s", strempty(ip_ingress), strempty(ip_egress));
+
+                        const char *io_read = NULL, *io_write = NULL;
 
+                        if (c.io_read_bytes != UINT64_MAX)
+                                io_read = strjoina(" read: %s", FORMAT_BYTES(c.io_read_bytes));
                         if (c.io_write_bytes != UINT64_MAX)
-                                log_info("IO bytes written: %s", FORMAT_BYTES(c.io_write_bytes));
+                                io_write = strjoina(" written: %s", FORMAT_BYTES(c.io_write_bytes));
+
+                        if (io_read || io_write)
+                                log_info("IO bytes%s%s", strempty(io_read), strempty(io_write));
                 }
 
                 /* Try to propagate the service's return value. But if the service defines