65878a
From 29323cff9feac15e1871a10e727690ac0ed1007d Mon Sep 17 00:00:00 2001
65878a
From: Lennart Poettering <lennart@poettering.net>
65878a
Date: Wed, 27 Nov 2013 01:54:25 +0100
65878a
Subject: [PATCH] journald: mention how long we needed to flush to /var in the
65878a
 logs
65878a
65878a
---
65878a
 src/journal/journald-server.c | 11 ++++++++++-
65878a
 1 file changed, 10 insertions(+), 1 deletion(-)
65878a
65878a
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
65878a
index e03e413..a0a8e9c 100644
65878a
--- a/src/journal/journald-server.c
65878a
+++ b/src/journal/journald-server.c
65878a
@@ -968,9 +968,12 @@ static int system_journal_open(Server *s) {
65878a
 }
65878a
 
65878a
 int server_flush_to_var(Server *s) {
65878a
-        int r;
65878a
         sd_id128_t machine;
65878a
         sd_journal *j = NULL;
65878a
+        char ts[FORMAT_TIMESPAN_MAX];
65878a
+        usec_t start;
65878a
+        unsigned n = 0;
65878a
+        int r;
65878a
 
65878a
         assert(s);
65878a
 
65878a
@@ -988,6 +991,8 @@ int server_flush_to_var(Server *s) {
65878a
 
65878a
         log_debug("Flushing to /var...");
65878a
 
65878a
+        start = now(CLOCK_MONOTONIC);
65878a
+
65878a
         r = sd_id128_get_machine(&machine);
65878a
         if (r < 0)
65878a
                 return r;
65878a
@@ -1007,6 +1012,8 @@ int server_flush_to_var(Server *s) {
65878a
                 f = j->current_file;
65878a
                 assert(f && f->current_offset > 0);
65878a
 
65878a
+                n++;
65878a
+
65878a
                 r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
65878a
                 if (r < 0) {
65878a
                         log_error("Can't read entry: %s", strerror(-r));
65878a
@@ -1050,6 +1057,8 @@ finish:
65878a
 
65878a
         sd_journal_close(j);
65878a
 
65878a
+        server_driver_message(s, SD_ID128_NULL, "Time spent on flushing to /var is %s for %u entries.", format_timespan(ts, sizeof(ts), now(CLOCK_MONOTONIC) - start, 0), n);
65878a
+
65878a
         return r;
65878a
 }
65878a