diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2012-05-13 18:18:54 +0200 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2012-05-14 14:29:53 +0200 |
commit | c69182961b00707d977957cf81d5c41cfbeab429 (patch) | |
tree | 0fea4038b59b5c82f71686c0ca50d118da983699 /src/core/job.c | |
parent | unit: print the color status marks on the left (diff) | |
download | systemd-c69182961b00707d977957cf81d5c41cfbeab429.tar.xz systemd-c69182961b00707d977957cf81d5c41cfbeab429.zip |
unit: unit type dependent status messages
Instead of generic "Starting..." and "Started" messages for all unit use
type-dependent messages. For example, mounts will announce "Mounting..."
and "Mounted".
Add status messages to units of types that used to be entirely silent
(automounts, sockets, targets, devices). For unit types whose jobs are
instantaneous, report only the job completion, not the starting event.
Socket units with non-instantaneous jobs are rare (Exec*= is not used
often in socket units), so I chose not to print the starting messages
for them either.
This will hopefully give people better understanding of the boot.
Diffstat (limited to 'src/core/job.c')
-rw-r--r-- | src/core/job.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/src/core/job.c b/src/core/job.c index 202eed198e..107961ae25 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -550,28 +550,37 @@ int job_run_and_invalidate(Job *j) { } static void job_print_status_message(Unit *u, JobType t, JobResult result) { - assert(u); + const UnitStatusMessageFormats *format_table; + const char *format; + + format_table = &UNIT_VTABLE(u)->status_message_formats; + if (!format_table) + return; if (t == JOB_START) { + format = format_table->finished_start_job[result]; + if (!format) + return; + switch (result) { case JOB_DONE: if (u->condition_result) - unit_status_printf(u, ANSI_HIGHLIGHT_GREEN_ON " OK " ANSI_HIGHLIGHT_OFF, "Started %s.", unit_description(u)); + unit_status_printf(u, ANSI_HIGHLIGHT_GREEN_ON " OK " ANSI_HIGHLIGHT_OFF, format, unit_description(u)); break; case JOB_FAILED: - unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON "FAILED" ANSI_HIGHLIGHT_OFF, "Failed to start %s.", unit_description(u)); - unit_status_printf(u, NULL, "See 'systemctl status %s' for details.", u->id); + unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON "FAILED" ANSI_HIGHLIGHT_OFF, format, unit_description(u)); + unit_status_printf(u, "", "See 'systemctl status %s' for details.", u->id); break; case JOB_DEPENDENCY: - unit_status_printf(u, ANSI_HIGHLIGHT_YELLOW_ON "DEPEND" ANSI_HIGHLIGHT_OFF, "Dependency failed. Aborted start of %s.", unit_description(u)); + unit_status_printf(u, ANSI_HIGHLIGHT_YELLOW_ON "DEPEND" ANSI_HIGHLIGHT_OFF, format, unit_description(u)); break; case JOB_TIMEOUT: - unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON " TIME " ANSI_HIGHLIGHT_OFF, "Timed out starting %s.", unit_description(u)); + unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON " TIME " ANSI_HIGHLIGHT_OFF, format, unit_description(u)); break; default: @@ -580,15 +589,19 @@ static void job_print_status_message(Unit *u, JobType t, JobResult result) { } else if (t == JOB_STOP) { + format = format_table->finished_stop_job[result]; + if (!format) + return; + switch (result) { case JOB_TIMEOUT: - unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON " TIME " ANSI_HIGHLIGHT_OFF, "Timed out stopping %s.", unit_description(u)); + unit_status_printf(u, ANSI_HIGHLIGHT_RED_ON " TIME " ANSI_HIGHLIGHT_OFF, format, unit_description(u)); break; case JOB_DONE: case JOB_FAILED: - unit_status_printf(u, ANSI_HIGHLIGHT_GREEN_ON " OK " ANSI_HIGHLIGHT_OFF, "Stopped %s.", unit_description(u)); + unit_status_printf(u, ANSI_HIGHLIGHT_GREEN_ON " OK " ANSI_HIGHLIGHT_OFF, format, unit_description(u)); break; default: @@ -607,34 +620,34 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive) { assert(j->installed); assert(j->type < _JOB_TYPE_MAX_IN_TRANSACTION); + u = j->unit; + t = j->type; + + j->result = result; + + log_debug("Job %s/%s finished, result=%s", u->id, job_type_to_string(t), job_result_to_string(result)); + + job_print_status_message(u, t, result); + job_add_to_dbus_queue(j); /* Patch restart jobs so that they become normal start jobs */ - if (result == JOB_DONE && j->type == JOB_RESTART) { + if (result == JOB_DONE && t == JOB_RESTART) { job_change_type(j, JOB_START); j->state = JOB_WAITING; job_add_to_run_queue(j); - u = j->unit; goto finish; } - j->result = result; - - log_debug("Job %s/%s finished, result=%s", j->unit->id, job_type_to_string(j->type), job_result_to_string(result)); - if (result == JOB_FAILED) j->manager->n_failed_jobs ++; - u = j->unit; - t = j->type; job_uninstall(j); job_free(j); - job_print_status_message(u, t, result); - /* Fail depending jobs on failure */ if (result != JOB_DONE && recursive) { |