summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2015-07-21 19:07:24 +0200
committerMichal Schmidt <mschmidt@redhat.com>2015-07-21 19:28:17 +0200
commit64f575d2ab9a6743d3c7172b7591c88ba243cf1b (patch)
tree8c38eb884c1fba43031a83d75bdad13b4be0c5d3
parentb81bbe5355b97d0d7dbe8796afd39bf284696063 (diff)
core: adjust job completion message log levels
We do not print all non-OK job completion status messages to the console in red, because not all of them are plain errors. We do however log the same messages as LOG_ERR. Differentiate the log levels by deducing them from the job result in a way that more or less matches the color of the console message.
-rw-r--r--src/core/job.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/core/job.c b/src/core/job.c
index 03ef1d5891..15f5cc0cc9 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -706,6 +706,17 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
const char *format;
char buf[LINE_MAX];
sd_id128_t mid;
+ static const int job_result_log_level[_JOB_RESULT_MAX] = {
+ [JOB_DONE] = LOG_INFO,
+ [JOB_CANCELED] = LOG_INFO,
+ [JOB_TIMEOUT] = LOG_ERR,
+ [JOB_FAILED] = LOG_ERR,
+ [JOB_DEPENDENCY] = LOG_WARNING,
+ [JOB_SKIPPED] = LOG_NOTICE,
+ [JOB_INVALID] = LOG_INFO,
+ [JOB_ASSERT] = LOG_WARNING,
+ [JOB_UNSUPPORTED] = LOG_WARNING,
+ };
assert(u);
assert(t >= 0);
@@ -732,7 +743,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
else if (t == JOB_RELOAD)
mid = SD_MESSAGE_UNIT_RELOADED;
else {
- log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
+ log_struct(job_result_log_level[result],
LOG_UNIT_ID(u),
LOG_MESSAGE("%s", buf),
"RESULT=%s", job_result_to_string(result),
@@ -740,7 +751,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
return;
}
- log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
+ log_struct(job_result_log_level[result],
LOG_MESSAGE_ID(mid),
LOG_UNIT_ID(u),
LOG_MESSAGE("%s", buf),