diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2015-07-20 17:18:13 +0200 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2015-07-21 15:09:12 +0200 |
commit | a85ca902c9f7f5aa8f2f3e3299147733802cf09d (patch) | |
tree | bbeb7204d8b2cd2ce52b0f441b5600aaca240ecc /src | |
parent | 2d018ae23b838f050516d06859f50ecb9733d44b (diff) |
core: always try harder to get unit status message format string
The starting/stopping messages are printed to the console only if the
corresponding format string is defined in the unit's vtable. To avoid
excessive messages on the console, the unit types whose start/stop
jobs are instantaneous had the format strings intentionally undefined.
When logging the same event to the journal, a fallback to generic
Starting/Stopping/Reloading messages is used.
The problem of excessive console messages with instantaneous jobs
is already resolved in a nicer way ("core: fix confusing logging of
instantaneous jobs"), so there's no longer a need to have two ways of
getting the format strings. Let's fold them into one function with
the fallback to generic message strings.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/unit.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index 4f5132586c..c0b5d02d35 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1318,32 +1318,21 @@ static bool unit_assert_test(Unit *u) { } _pure_ static const char* unit_get_status_message_format(Unit *u, JobType t) { - const UnitStatusMessageFormats *format_table; - - assert(u); - assert(t >= 0); - assert(t < _JOB_TYPE_MAX); - - if (t != JOB_START && t != JOB_STOP) - return NULL; - - format_table = &UNIT_VTABLE(u)->status_message_formats; - if (!format_table) - return NULL; - - return format_table->starting_stopping[t == JOB_STOP]; -} - -_pure_ static const char *unit_get_status_message_format_try_harder(Unit *u, JobType t) { const char *format; + const UnitStatusMessageFormats *format_table; assert(u); assert(t >= 0); assert(t < _JOB_TYPE_MAX); - format = unit_get_status_message_format(u, t); - if (format) - return format; + if (t == JOB_START || t == JOB_STOP) { + format_table = &UNIT_VTABLE(u)->status_message_formats; + if (format_table) { + format = format_table->starting_stopping[t == JOB_STOP]; + if (format) + return format; + } + } /* Return generic strings */ if (t == JOB_START) @@ -1361,9 +1350,6 @@ static void unit_status_print_starting_stopping(Unit *u, JobType t) { assert(u); - /* We only print status messages for selected units on - * selected operations. */ - format = unit_get_status_message_format(u, t); if (!format) return; @@ -1388,7 +1374,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) { /* We log status messages for all units and all operations. */ - format = unit_get_status_message_format_try_harder(u, t); + format = unit_get_status_message_format(u, t); if (!format) return; |