]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
manager: improve message about Reload/Reexec requests
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 8 Feb 2023 10:36:22 +0000 (11:36 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 8 Feb 2023 14:48:43 +0000 (15:48 +0100)
If we fail to get the necessary information, let's just not print that
part of the message. 'n/a' looks pretty ugly.

I used a bunch of ternary operators instead of seperate log lines because
with two components that might or might not be there, we need four different
combinations.

Also, the unit name doesn't need to be quoted, it's always printable.

src/core/dbus-manager.c

index 53121fa1a6bd89fe92384dcc077205f122607bc3..c4f205bc423f6d5de87baa58ad399fec7a7160ab 100644 (file)
@@ -1527,8 +1527,10 @@ static void log_caller(sd_bus_message *message, Manager *manager, const char *me
         (void) sd_bus_creds_get_comm(creds, &comm);
         caller = manager_get_unit_by_pid(manager, pid);
 
-        log_info("%s requested from client PID " PID_FMT " ('%s') (from unit '%s')...",
-                 method, pid, strna(comm), strna(caller ? caller->id : NULL));
+        log_info("%s requested from client PID " PID_FMT "%s%s%s%s%s%s...",
+                 method, pid,
+                 comm ? " ('" : "", strempty(comm), comm ? "')" : "",
+                 caller ? " (unit " : "", caller ? caller->id : NULL, caller ? ")" : "");
 }
 
 static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) {