manager: improve message about Reload/Reexec requests

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-02-08 15:48:43 +01:00
parent a99bd455b5
commit 1980a25dc0
+4 -2
View 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) {