log: introduce a macro to format message id

The MESSAGE_ID=... stanza will appear in countless number of places.
It is just too long to write it out in full each time.

Incidentally, this also fixes a typo of MESSSAGE is three places.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2012-10-13 14:26:30 +02:00
parent c0735bb218
commit 1ca6783f5e
10 changed files with 20 additions and 20 deletions
+3 -3
View File
@@ -705,7 +705,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
mid = result == JOB_DONE ? SD_MESSAGE_UNIT_STARTED : SD_MESSAGE_UNIT_FAILED;
log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
"MESSSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(mid),
MESSAGE_ID(mid),
"UNIT=%s", u->id,
"RESULT=%s", job_result_to_string(result),
"MESSAGE=%s", buf,
@@ -713,7 +713,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
} else if (t == JOB_STOP)
log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
"MESSSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_UNIT_STOPPED),
MESSAGE_ID(SD_MESSAGE_UNIT_STOPPED),
"UNIT=%s", u->id,
"RESULT=%s", job_result_to_string(result),
"MESSAGE=%s", buf,
@@ -721,7 +721,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
else if (t == JOB_RELOAD)
log_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
"MESSSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_UNIT_RELOADED),
MESSAGE_ID(SD_MESSAGE_UNIT_RELOADED),
"UNIT=%s", u->id,
"RESULT=%s", job_result_to_string(result),
"MESSAGE=%s", buf,
+3 -3
View File
@@ -2039,7 +2039,7 @@ void manager_check_finished(Manager *m) {
if (!log_on_console())
log_struct(LOG_INFO,
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_STARTUP_FINISHED),
MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
"KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
"INITRD_USEC=%llu", (unsigned long long) initrd_usec,
"USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
@@ -2055,7 +2055,7 @@ void manager_check_finished(Manager *m) {
if (!log_on_console())
log_struct(LOG_INFO,
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_STARTUP_FINISHED),
MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
"KERNEL_USEC=%llu", (unsigned long long) kernel_usec,
"USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
"MESSAGE=Startup finished in %s (kernel) + %s (userspace) = %s.",
@@ -2070,7 +2070,7 @@ void manager_check_finished(Manager *m) {
if (!log_on_console())
log_struct(LOG_INFO,
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_STARTUP_FINISHED),
MESSAGE_ID(SD_MESSAGE_STARTUP_FINISHED),
"USERSPACE_USEC=%llu", (unsigned long long) userspace_usec,
"MESSAGE=Startup finished in %s.",
format_timespan(sum, sizeof(sum), total_usec),
+1 -1
View File
@@ -1023,7 +1023,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
SD_MESSAGE_UNIT_RELOADING;
log_struct(LOG_INFO,
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(mid),
MESSAGE_ID(mid),
"UNIT=%s", u->id,
"MESSAGE=%s", buf,
NULL);