|
|
aed857 |
From c571dc5f7d593a4526da9e19b35ae3d1ed11bfaa Mon Sep 17 00:00:00 2001
|
|
|
aed857 |
From: Michal Schmidt <mschmidt@redhat.com>
|
|
|
aed857 |
Date: Mon, 20 Jul 2015 17:18:13 +0200
|
|
|
aed857 |
Subject: [PATCH] core: always try harder to get unit status message format
|
|
|
aed857 |
string
|
|
|
aed857 |
|
|
|
aed857 |
The starting/stopping messages are printed to the console only if the
|
|
|
aed857 |
corresponding format string is defined in the unit's vtable. To avoid
|
|
|
aed857 |
excessive messages on the console, the unit types whose start/stop
|
|
|
aed857 |
jobs are instantaneous had the format strings intentionally undefined.
|
|
|
aed857 |
When logging the same event to the journal, a fallback to generic
|
|
|
aed857 |
Starting/Stopping/Reloading messages is used.
|
|
|
aed857 |
|
|
|
aed857 |
The problem of excessive console messages with instantaneous jobs
|
|
|
aed857 |
is already resolved in a nicer way ("core: fix confusing logging of
|
|
|
aed857 |
instantaneous jobs"), so there's no longer a need to have two ways of
|
|
|
aed857 |
getting the format strings. Let's fold them into one function with
|
|
|
aed857 |
the fallback to generic message strings.
|
|
|
aed857 |
|
|
|
aed857 |
(cherry picked from commit a85ca902c9f7f5aa8f2f3e3299147733802cf09d)
|
|
|
aed857 |
|
|
|
aed857 |
Related: #1506256
|
|
|
aed857 |
---
|
|
|
aed857 |
src/core/unit.c | 34 ++++++++++------------------------
|
|
|
aed857 |
1 file changed, 10 insertions(+), 24 deletions(-)
|
|
|
aed857 |
|
|
|
aed857 |
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
|
aed857 |
index 907a4bf7f..a33cbdf73 100644
|
|
|
aed857 |
--- a/src/core/unit.c
|
|
|
aed857 |
+++ b/src/core/unit.c
|
|
|
aed857 |
@@ -1328,32 +1328,21 @@ static bool unit_assert_test(Unit *u) {
|
|
|
aed857 |
}
|
|
|
aed857 |
|
|
|
aed857 |
_pure_ static const char* unit_get_status_message_format(Unit *u, JobType t) {
|
|
|
aed857 |
- const UnitStatusMessageFormats *format_table;
|
|
|
aed857 |
-
|
|
|
aed857 |
- assert(u);
|
|
|
aed857 |
- assert(t >= 0);
|
|
|
aed857 |
- assert(t < _JOB_TYPE_MAX);
|
|
|
aed857 |
-
|
|
|
aed857 |
- if (t != JOB_START && t != JOB_STOP)
|
|
|
aed857 |
- return NULL;
|
|
|
aed857 |
-
|
|
|
aed857 |
- format_table = &UNIT_VTABLE(u)->status_message_formats;
|
|
|
aed857 |
- if (!format_table)
|
|
|
aed857 |
- return NULL;
|
|
|
aed857 |
-
|
|
|
aed857 |
- return format_table->starting_stopping[t == JOB_STOP];
|
|
|
aed857 |
-}
|
|
|
aed857 |
-
|
|
|
aed857 |
-_pure_ static const char *unit_get_status_message_format_try_harder(Unit *u, JobType t) {
|
|
|
aed857 |
const char *format;
|
|
|
aed857 |
+ const UnitStatusMessageFormats *format_table;
|
|
|
aed857 |
|
|
|
aed857 |
assert(u);
|
|
|
aed857 |
assert(t >= 0);
|
|
|
aed857 |
assert(t < _JOB_TYPE_MAX);
|
|
|
aed857 |
|
|
|
aed857 |
- format = unit_get_status_message_format(u, t);
|
|
|
aed857 |
- if (format)
|
|
|
aed857 |
- return format;
|
|
|
aed857 |
+ if (t == JOB_START || t == JOB_STOP) {
|
|
|
aed857 |
+ format_table = &UNIT_VTABLE(u)->status_message_formats;
|
|
|
aed857 |
+ if (format_table) {
|
|
|
aed857 |
+ format = format_table->starting_stopping[t == JOB_STOP];
|
|
|
aed857 |
+ if (format)
|
|
|
aed857 |
+ return format;
|
|
|
aed857 |
+ }
|
|
|
aed857 |
+ }
|
|
|
aed857 |
|
|
|
aed857 |
/* Return generic strings */
|
|
|
aed857 |
if (t == JOB_START)
|
|
|
aed857 |
@@ -1371,9 +1360,6 @@ static void unit_status_print_starting_stopping(Unit *u, JobType t) {
|
|
|
aed857 |
|
|
|
aed857 |
assert(u);
|
|
|
aed857 |
|
|
|
aed857 |
- /* We only print status messages for selected units on
|
|
|
aed857 |
- * selected operations. */
|
|
|
aed857 |
-
|
|
|
aed857 |
format = unit_get_status_message_format(u, t);
|
|
|
aed857 |
if (!format)
|
|
|
aed857 |
return;
|
|
|
aed857 |
@@ -1398,7 +1384,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
|
|
|
aed857 |
|
|
|
aed857 |
/* We log status messages for all units and all operations. */
|
|
|
aed857 |
|
|
|
aed857 |
- format = unit_get_status_message_format_try_harder(u, t);
|
|
|
aed857 |
+ format = unit_get_status_message_format(u, t);
|
|
|
aed857 |
if (!format)
|
|
|
aed857 |
return;
|
|
|
aed857 |
|