summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2015-07-21 17:26:28 +0200
committerMichal Schmidt <mschmidt@redhat.com>2015-07-21 19:24:20 +0200
commitb81bbe5355b97d0d7dbe8796afd39bf284696063 (patch)
treefd73384a1ce0cb082d158b7912f088246702b27c
parent4f29c6fea6a6c5c2c9406ad091cd6f56da21e2cb (diff)
core: small refactor of job completion logging
Joins three log_struct() calls into one.
-rw-r--r--src/core/job.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/src/core/job.c b/src/core/job.c
index 0f0fe1994a..03ef1d5891 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -705,6 +705,7 @@ static void job_print_status_message(Unit *u, JobType t, JobResult result) {
static void job_log_status_message(Unit *u, JobType t, JobResult result) {
const char *format;
char buf[LINE_MAX];
+ sd_id128_t mid;
assert(u);
assert(t >= 0);
@@ -724,38 +725,27 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
snprintf(buf, sizeof(buf), format, unit_description(u));
REENABLE_WARNING;
- if (t == JOB_START) {
- sd_id128_t mid;
-
+ if (t == JOB_START)
mid = result == JOB_DONE ? SD_MESSAGE_UNIT_STARTED : SD_MESSAGE_UNIT_FAILED;
- log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
- LOG_MESSAGE_ID(mid),
- LOG_UNIT_ID(u),
- LOG_MESSAGE("%s", buf),
- "RESULT=%s", job_result_to_string(result),
- NULL);
-
- } else if (t == JOB_STOP || t == JOB_RESTART)
- log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
- LOG_MESSAGE_ID(SD_MESSAGE_UNIT_STOPPED),
- LOG_UNIT_ID(u),
- LOG_MESSAGE("%s", buf),
- "RESULT=%s", job_result_to_string(result),
- NULL);
-
+ else if (t == JOB_STOP || t == JOB_RESTART)
+ mid = SD_MESSAGE_UNIT_STOPPED;
else if (t == JOB_RELOAD)
- log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
- LOG_MESSAGE_ID(SD_MESSAGE_UNIT_RELOADED),
- LOG_UNIT_ID(u),
- LOG_MESSAGE("%s", buf),
- "RESULT=%s", job_result_to_string(result),
- NULL);
- else
+ mid = SD_MESSAGE_UNIT_RELOADED;
+ else {
log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
LOG_UNIT_ID(u),
LOG_MESSAGE("%s", buf),
"RESULT=%s", job_result_to_string(result),
NULL);
+ return;
+ }
+
+ log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
+ LOG_MESSAGE_ID(mid),
+ LOG_UNIT_ID(u),
+ LOG_MESSAGE("%s", buf),
+ "RESULT=%s", job_result_to_string(result),
+ NULL);
}
static void job_emit_status_message(Unit *u, JobType t, JobResult result) {