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,
}
line ++;
+ maybe_print_begin_newline(f, &flags);
r = output_journal(f, j, mode, n_columns, flags, ellipsized);
if (r < 0)
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;
}
OUTPUT_WARN_CUTOFF = 1 << 2,
OUTPUT_FULL_WIDTH = 1 << 3,
OUTPUT_COLOR = 1 << 4,
- OUTPUT_CATALOG = 1 << 5
+ OUTPUT_CATALOG = 1 << 5,
+ OUTPUT_BEGIN_NEWLINE = 1 << 6,
} OutputFlags;
}
if (i->id && arg_transport == BUS_TRANSPORT_LOCAL) {
- printf("\n");
show_journal_by_unit(stdout,
i->id,
arg_output,
i->inactive_exit_timestamp_monotonic,
arg_lines,
getuid(),
- flags,
+ flags | OUTPUT_BEGIN_NEWLINE,
arg_scope == UNIT_FILE_SYSTEM,
ellipsized);
}