return true;
}
-static void print_multiline(FILE *f, unsigned prefix, unsigned n_columns, OutputMode flags, int priority, const char* message, size_t message_len) {
+static bool print_multiline(FILE *f, unsigned prefix, unsigned n_columns, OutputMode flags, int priority, const char* message, size_t message_len) {
const char *color_on = "", *color_off = "";
const char *pos, *end;
bool continuation = false;
+ bool ellipsized = false;
if (flags & OUTPUT_COLOR) {
if (priority <= LOG_ERR) {
else if (prefix < n_columns && n_columns - prefix >= 3) {
_cleanup_free_ char *e;
+ ellipsized = true;
e = ellipsize_mem(pos, len, n_columns - prefix, 90);
if (!e)
- fprintf(f, "%s%.*s%s\n", color_on, len, pos, color_off);
+ fprintf(f, "%*s%s%.*s%s\n",
+ continuation * prefix, "",
+ color_on, len, pos, color_off);
else
- fprintf(f, "%s%s%s\n", color_on, e, color_off);
- } else
+ fprintf(f, "%*s%s%s%s\n",
+ continuation * prefix, "",
+ color_on, e, color_off);
+ } else {
+ ellipsized = true;
fputs("...\n", f);
+ }
continuation = true;
}
+
+ return ellipsized;
}
static int output_short(
_cleanup_free_ char *hostname = NULL, *identifier = NULL, *comm = NULL, *pid = NULL, *fake_pid = NULL, *message = NULL, *realtime = NULL, *monotonic = NULL, *priority = NULL;
size_t hostname_len = 0, identifier_len = 0, comm_len = 0, pid_len = 0, fake_pid_len = 0, message_len = 0, realtime_len = 0, monotonic_len = 0, priority_len = 0;
int p = LOG_INFO;
+ bool ellipsized = false;
assert(f);
assert(j);
- sd_journal_set_data_threshold(j, flags & OUTPUT_SHOW_ALL ? 0 : PRINT_THRESHOLD);
+ sd_journal_set_data_threshold(j, flags & (OUTPUT_SHOW_ALL|OUTPUT_FULL_WIDTH) ? 0 : PRINT_THRESHOLD);
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r) {
}
t = (time_t) (x / USEC_PER_SEC);
- if (strftime(buf, sizeof(buf), "%b %d %H:%M:%S", localtime_r(&t, &tm)) <= 0) {
+ if (mode == OUTPUT_SHORT_ISO)
+ r = strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", localtime_r(&t, &tm));
+ else
+ r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", localtime_r(&t, &tm));
+
+ if (r <= 0) {
log_error("Failed to format time.");
- return r;
+ return -EINVAL;
}
fputs(buf, f);
fprintf(f, ": [%s blob data]\n", format_bytes(bytes, sizeof(bytes), message_len));
} else {
fputs(": ", f);
- print_multiline(f, n + 2, n_columns, flags, p, message, message_len);
+ ellipsized |=
+ print_multiline(f, n + 2, n_columns, flags, p, message, message_len);
}
if (flags & OUTPUT_CATALOG)
print_catalog(f, j);
- return 0;
+ return ellipsized;
}
static int output_verbose(
[OUTPUT_SHORT] = output_short,
[OUTPUT_SHORT_MONOTONIC] = output_short,
+ [OUTPUT_SHORT_ISO] = output_short,
[OUTPUT_VERBOSE] = output_verbose,
[OUTPUT_EXPORT] = output_export,
[OUTPUT_JSON] = output_json,
sd_journal *j,
OutputMode mode,
unsigned n_columns,
- OutputFlags flags) {
+ OutputFlags flags,
+ bool *ellipsized) {
int ret;
assert(mode >= 0);
ret = output_funcs[mode](f, j, mode, n_columns, flags);
fflush(stdout);
+
+ if (ellipsized && ret > 0)
+ *ellipsized = true;
+
return ret;
}
unsigned n_columns,
usec_t not_before,
unsigned how_many,
- OutputFlags flags) {
+ OutputFlags flags,
+ bool *ellipsized) {
int r;
unsigned line = 0;
line ++;
- r = output_journal(f, j, mode, n_columns, flags);
+ r = output_journal(f, j, mode, n_columns, flags, ellipsized);
if (r < 0)
goto finish;
}
unsigned how_many,
uid_t uid,
OutputFlags flags,
- bool system) {
+ bool system,
+ bool *ellipsized) {
_cleanup_journal_close_ sd_journal*j = NULL;
int r;
log_debug("Journal filter: %s", filter);
}
- r = show_journal(f, j, mode, n_columns, not_before, how_many, flags);
- if (r < 0)
- return r;
-
- return 0;
+ return show_journal(f, j, mode, n_columns, not_before, how_many, flags, ellipsized);
}
static const char *const output_mode_table[_OUTPUT_MODE_MAX] = {
[OUTPUT_SHORT] = "short",
[OUTPUT_SHORT_MONOTONIC] = "short-monotonic",
+ [OUTPUT_SHORT_ISO] = "short-iso",
[OUTPUT_VERBOSE] = "verbose",
[OUTPUT_EXPORT] = "export",
[OUTPUT_JSON] = "json",