From 1ca6783f5ea3755bd83e723f529c2eda512c7fed Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 8 Oct 2012 17:02:30 +0000 Subject: 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. --- src/core/job.c | 6 +++--- src/core/manager.c | 6 +++--- src/core/unit.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/core') diff --git a/src/core/job.c b/src/core/job.c index 706910b695..cb5674b5a8 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -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, diff --git a/src/core/manager.c b/src/core/manager.c index 6fecbc3f71..b19fc3d508 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -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), diff --git a/src/core/unit.c b/src/core/unit.c index ae43545c6f..6396bfc09f 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -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); -- cgit v1.2.3-54-g00ecf