summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-26 19:48:24 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-26 19:52:00 -0400
commit7ac4fa7e92c782f2978260023cff64aa683e6011 (patch)
treed11b4b0b57b113f69b879960f3effba82139cd08 /src
parent785a51eb682136b2c7ee33fabe64c72d20fa37db (diff)
downloadsystemd-7ac4fa7e92c782f2978260023cff64aa683e6011.tar.gz
journalctl: highlight MESSAGE= in verbose output
When looking at verbose output, additional "work" is required to pick out the interesting MESSAGE= lines from all the fields. Also, show long fields in full in verbose output mode when OUTPUT_FULL_WIDTH is specified.
Diffstat (limited to 'src')
-rw-r--r--src/shared/logs-show.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 91b2bec159..8dc11bb7fd 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -357,6 +357,8 @@ static int output_verbose(
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r) {
const char *c;
int fieldlen;
+ const char *on = "", *off = "";
+
c = memchr(data, '=', length);
if (!c) {
log_error("Invalid field.");
@@ -364,16 +366,25 @@ static int output_verbose(
}
fieldlen = c - (const char*) data;
- if ((flags & OUTPUT_SHOW_ALL) || (length < PRINT_THRESHOLD && utf8_is_printable(data, length))) {
- fprintf(f, " %.*s=", fieldlen, (const char*)data);
+ if (flags & OUTPUT_COLOR && startswith(data, "MESSAGE=")) {
+ on = ANSI_HIGHLIGHT_ON;
+ off = ANSI_HIGHLIGHT_OFF;
+ }
+
+ if (flags & OUTPUT_SHOW_ALL ||
+ (((length < PRINT_THRESHOLD) || flags & OUTPUT_FULL_WIDTH) && utf8_is_printable(data, length))) {
+ fprintf(f, " %s%.*s=", on, fieldlen, (const char*)data);
print_multiline(f, 4 + fieldlen + 1, 0, OUTPUT_FULL_WIDTH, 0, c + 1, length - fieldlen - 1);
+ fputs(off, f);
} else {
char bytes[FORMAT_BYTES_MAX];
- fprintf(f, " %.*s=[%s blob data]\n",
+ fprintf(f, " %s%.*s=[%s blob data]%s\n",
+ on,
(int) (c - (const char*) data),
(const char*) data,
- format_bytes(bytes, sizeof(bytes), length - (c - (const char *) data) - 1));
+ format_bytes(bytes, sizeof(bytes), length - (c - (const char *) data) - 1),
+ off);
}
}