From 81270860a5b8c6794f0c7bac8becfdd0c41a9385 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 24 Aug 2012 22:43:33 +0200 Subject: journal: suppress structured messages if they'd go to the console --- src/core/job.c | 6 ++++++ src/core/manager.c | 55 ++++++++++++++++++++++++++++-------------------------- src/core/unit.c | 3 +++ 3 files changed, 38 insertions(+), 26 deletions(-) (limited to 'src/core') diff --git a/src/core/job.c b/src/core/job.c index 9614642f56..706910b695 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -687,6 +687,12 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) { assert(t >= 0); assert(t < _JOB_TYPE_MAX); + /* Skip this if it goes to the console. since we already print + * to the console anyway... */ + + if (log_on_console()) + return; + format = job_get_status_message_format_try_harder(u, t, result); if (!format) return; diff --git a/src/core/manager.c b/src/core/manager.c index da766e6d58..40b0c50851 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2032,41 +2032,44 @@ void manager_check_finished(Manager *m) { kernel_usec = m->initrd_timestamp.monotonic; initrd_usec = m->startup_timestamp.monotonic - m->initrd_timestamp.monotonic; - log_struct(LOG_INFO, - "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(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, - "MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.", - format_timespan(kernel, sizeof(kernel), kernel_usec), - format_timespan(initrd, sizeof(initrd), initrd_usec), - format_timespan(userspace, sizeof(userspace), userspace_usec), - format_timespan(sum, sizeof(sum), total_usec), - NULL); + if (!log_on_console()) + log_struct(LOG_INFO, + "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(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, + "MESSAGE=Startup finished in %s (kernel) + %s (initrd) + %s (userspace) = %s.", + format_timespan(kernel, sizeof(kernel), kernel_usec), + format_timespan(initrd, sizeof(initrd), initrd_usec), + format_timespan(userspace, sizeof(userspace), userspace_usec), + format_timespan(sum, sizeof(sum), total_usec), + NULL); } else { kernel_usec = m->startup_timestamp.monotonic; initrd_usec = 0; - log_struct(LOG_INFO, - "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(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.", - format_timespan(kernel, sizeof(kernel), kernel_usec), - format_timespan(userspace, sizeof(userspace), userspace_usec), - format_timespan(sum, sizeof(sum), total_usec), - NULL); + if (!log_on_console()) + log_struct(LOG_INFO, + "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(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.", + format_timespan(kernel, sizeof(kernel), kernel_usec), + format_timespan(userspace, sizeof(userspace), userspace_usec), + format_timespan(sum, sizeof(sum), total_usec), + NULL); } } else { initrd_usec = kernel_usec = 0; total_usec = userspace_usec = m->finish_timestamp.monotonic - m->startup_timestamp.monotonic; - log_struct(LOG_INFO, - "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_STARTUP_FINISHED), - "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec, - "MESSAGE=Startup finished in %s.", - format_timespan(sum, sizeof(sum), total_usec), - NULL); + if (!log_on_console()) + log_struct(LOG_INFO, + "MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(SD_MESSAGE_STARTUP_FINISHED), + "USERSPACE_USEC=%llu", (unsigned long long) userspace_usec, + "MESSAGE=Startup finished in %s.", + format_timespan(sum, sizeof(sum), total_usec), + NULL); } bus_broadcast_finished(m, kernel_usec, initrd_usec, userspace_usec, total_usec); diff --git a/src/core/unit.c b/src/core/unit.c index 8246837658..ba4c7d5b32 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1004,6 +1004,9 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) { if (t != JOB_START && t != JOB_STOP && t != JOB_RELOAD) return; + if (log_on_console()) + return; + /* We log status messages for all units and all operations. */ format = unit_get_status_message_format_try_harder(u, t); -- cgit v1.2.3-54-g00ecf