]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Use unit->id instead of description in messages 12755/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 6 Jun 2019 15:33:59 +0000 (17:33 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 10 Jul 2019 11:35:26 +0000 (13:35 +0200)
v2:
- rename unit_identifier to unit_status_string

TODO
src/core/job.c
src/core/manager.c
src/core/unit.c
src/core/unit.h

diff --git a/TODO b/TODO
index a575f9ab737cf356c7004debd556cdf8cc96336b..0df3a624030248c344727740c6976a1e8fa46f58 100644 (file)
--- a/TODO
+++ b/TODO
@@ -524,8 +524,6 @@ Features:
 
 * maybe add support for specifier expansion in user.conf, specifically DefaultEnvironment=
 
-* consider showing the unit names during boot up in the status output, not just the unit descriptions
-
 * maybe allow timer units with an empty Units= setting, so that they
   can be used for resuming the system but nothing else.
 
index df7eacfbc04b6102cd50ba2920651d3117097274..c69ccc221d1f5d5a0e67e2388c7bfc9e87298e33 100644 (file)
@@ -579,7 +579,7 @@ static void job_log_begin_status_message(Unit *u, uint32_t job_id, JobType t) {
         format = job_get_begin_status_message_format(u, t);
 
         DISABLE_WARNING_FORMAT_NONLITERAL;
-        (void) snprintf(buf, sizeof buf, format, unit_description(u));
+        (void) snprintf(buf, sizeof buf, format, unit_status_string(u));
         REENABLE_WARNING;
 
         mid = t == JOB_START ? "MESSAGE_ID=" SD_MESSAGE_UNIT_STARTING_STR :
@@ -889,7 +889,7 @@ static void job_log_done_status_message(Unit *u, uint32_t job_id, JobType t, Job
         /* Show condition check message if the job did not actually do anything due to failed condition. */
         if (t == JOB_START && result == JOB_DONE && !u->condition_result) {
                 log_struct(LOG_INFO,
-                           "MESSAGE=Condition check resulted in %s being skipped.", unit_description(u),
+                           "MESSAGE=Condition check resulted in %s being skipped.", unit_status_string(u),
                            "JOB_ID=%" PRIu32, job_id,
                            "JOB_TYPE=%s", job_type_to_string(t),
                            "JOB_RESULT=%s", job_result_to_string(result),
@@ -909,7 +909,7 @@ static void job_log_done_status_message(Unit *u, uint32_t job_id, JobType t, Job
          * xsprintf() on purpose here: we are fine with truncation and don't
          * consider that an error. */
         DISABLE_WARNING_FORMAT_NONLITERAL;
-        (void) snprintf(buf, sizeof(buf), format, unit_description(u));
+        (void) snprintf(buf, sizeof(buf), format, unit_status_string(u));
         REENABLE_WARNING;
 
         switch (t) {
index 6b89a5c5bbd3a728497b134edbf87e8a3c6efd80..09507648fb1a2e88b2f2c9e59f84dbde7e510110 100644 (file)
@@ -231,7 +231,7 @@ static void manager_print_jobs_in_progress(Manager *m) {
                               "%sA %s job is running for %s (%s / %s)",
                               strempty(job_of_n),
                               job_type_to_string(j->type),
-                              unit_description(j->unit),
+                              unit_status_string(j->unit),
                               time, limit);
 }
 
index 463db73ff1a118e5a7bd6d015551f188f6c952ef..71eb988cd6caa0860ec9f9ba2499aecee492e82d 100644 (file)
@@ -1067,6 +1067,15 @@ const char *unit_description(Unit *u) {
         return strna(u->id);
 }
 
+const char *unit_status_string(Unit *u) {
+        assert(u);
+
+        if (u->manager->status_unit_format == STATUS_UNIT_FORMAT_NAME && u->id)
+                return u->id;
+
+        return unit_description(u);
+}
+
 static void print_unit_dependency_mask(FILE *f, const char *kind, UnitDependencyMask mask, bool *space) {
         const struct {
                 UnitDependencyMask mask;
@@ -1644,7 +1653,7 @@ static bool unit_test_assert(Unit *u) {
 void unit_status_printf(Unit *u, const char *status, const char *unit_status_msg_format) {
         const char *d;
 
-        d = unit_description(u);
+        d = unit_status_string(u);
         if (log_get_show_color())
                 d = strjoina(ANSI_HIGHLIGHT, d, ANSI_NORMAL);
 
index ef495f836bdfeaa8f4ca054be5ccb1ab546c2dab..e7bfc6b4a7165568a8d28ef3a74aad6f278a959b 100644 (file)
@@ -671,6 +671,7 @@ int unit_set_slice(Unit *u, Unit *slice);
 int unit_set_default_slice(Unit *u);
 
 const char *unit_description(Unit *u) _pure_;
+const char *unit_status_string(Unit *u) _pure_;
 
 bool unit_has_name(const Unit *u, const char *name);