summaryrefslogtreecommitdiff
path: root/src/shared/logs-show.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-13 03:58:03 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-13 04:17:37 +0100
commitea6c2dd1f819c3d481fc590849809aeb552c1d48 (patch)
tree0af9968a0317503e9ea703ddf02e96a8defb8607 /src/shared/logs-show.c
parent15ef11449b31e2fc91f2172c8afedb20ecad5ae9 (diff)
systemctl: suppress duplicate newline if there's not log output in "systemctl status"
Diffstat (limited to 'src/shared/logs-show.c')
-rw-r--r--src/shared/logs-show.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 12d4a1caec..f7d84fc723 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -927,6 +927,21 @@ int output_journal(
return ret;
}
+static int maybe_print_begin_newline(FILE *f, OutputFlags *flags) {
+ assert(f);
+ assert(flags);
+
+ if (!(*flags & OUTPUT_BEGIN_NEWLINE))
+ return 0;
+
+ /* Print a beginning new line if that's request, but only once
+ * on the first line we print. */
+
+ fputc('\n', f);
+ *flags &= ~OUTPUT_BEGIN_NEWLINE;
+ return 0;
+}
+
static int show_journal(FILE *f,
sd_journal *j,
OutputMode mode,
@@ -984,6 +999,7 @@ static int show_journal(FILE *f,
}
line ++;
+ maybe_print_begin_newline(f, &flags);
r = output_journal(f, j, mode, n_columns, flags, ellipsized);
if (r < 0)
@@ -1004,8 +1020,10 @@ static int show_journal(FILE *f,
if (r < 0)
goto finish;
- if (r > 0 && not_before < cutoff)
+ if (r > 0 && not_before < cutoff) {
+ maybe_print_begin_newline(f, &flags);
fprintf(f, "Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.\n");
+ }
warn_cutoff = false;
}