aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-05-24 10:43:07 +0200
committerGitHub <noreply@github.com>2019-05-24 10:43:07 +0200
commitd631a760e09b7e6eb9d47ce933635771c736ac6f (patch)
treee2848be12fa9c601f1772f283bc1f89d2e066959
parentMerge pull request #12590 from keszybz/unicode-cmdlines (diff)
parentshared/logs-show: show audit logs in blue (diff)
downloadsystemd-d631a760e09b7e6eb9d47ce933635771c736ac6f.tar.xz
systemd-d631a760e09b7e6eb9d47ce933635771c736ac6f.zip
Merge pull request #12601 from keszybz/two-log-color-adjustments
Two log color adjustments
-rw-r--r--src/basic/terminal-util.h2
-rw-r--r--src/shared/logs-show.c25
2 files changed, 20 insertions, 7 deletions
diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h
index ae9cda403b8..90adc14d176 100644
--- a/src/basic/terminal-util.h
+++ b/src/basic/terminal-util.h
@@ -21,7 +21,7 @@
/* Bold/highlighted */
#define ANSI_HIGHLIGHT_RED "\x1B[0;1;31m"
#define ANSI_HIGHLIGHT_GREEN "\x1B[0;1;32m"
-#define ANSI_HIGHLIGHT_YELLOW "\x1B[0;1;33m"
+#define ANSI_HIGHLIGHT_YELLOW "\x1B[0;1;38;5;185m"
#define ANSI_HIGHLIGHT_BLUE "\x1B[0;1;34m"
#define ANSI_HIGHLIGHT_MAGENTA "\x1B[0;1;35m"
#define ANSI_HIGHLIGHT_GREY "\x1B[0;1;38;5;245m"
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index bdde6c11e38..aa5bc5b4ed7 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -154,6 +154,7 @@ static bool print_multiline(
unsigned n_columns,
OutputFlags flags,
int priority,
+ bool audit,
const char* message,
size_t message_len,
size_t highlight[2]) {
@@ -163,9 +164,15 @@ static bool print_multiline(
bool ellipsized = false;
int line = 0;
- if (flags & OUTPUT_COLOR)
+ if (flags & OUTPUT_COLOR) {
get_log_colors(priority, &color_on, &color_off, &highlight_on);
+ if (audit && strempty(color_on)) {
+ color_on = ANSI_BLUE;
+ color_off = ANSI_NORMAL;
+ }
+ }
+
/* A special case: make sure that we print a newline when
the message is empty. */
if (message_len == 0)
@@ -368,15 +375,16 @@ static int output_short(
const void *data;
size_t length;
size_t n = 0;
- _cleanup_free_ char *hostname = NULL, *identifier = NULL, *comm = NULL, *pid = NULL, *fake_pid = NULL, *message = NULL, *realtime = NULL, *monotonic = NULL, *priority = NULL, *unit = NULL, *user_unit = 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, unit_len = 0, user_unit_len = 0;
+ _cleanup_free_ char *hostname = NULL, *identifier = NULL, *comm = NULL, *pid = NULL, *fake_pid = NULL, *message = NULL, *realtime = NULL, *monotonic = NULL, *priority = NULL, *transport = NULL, *unit = NULL, *user_unit = 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, transport_len = 0, unit_len = 0, user_unit_len = 0;
int p = LOG_INFO;
- bool ellipsized = false;
+ bool ellipsized = false, audit;
const ParseFieldVec fields[] = {
PARSE_FIELD_VEC_ENTRY("_PID=", &pid, &pid_len),
PARSE_FIELD_VEC_ENTRY("_COMM=", &comm, &comm_len),
PARSE_FIELD_VEC_ENTRY("MESSAGE=", &message, &message_len),
PARSE_FIELD_VEC_ENTRY("PRIORITY=", &priority, &priority_len),
+ PARSE_FIELD_VEC_ENTRY("_TRANSPORT=", &transport, &transport_len),
PARSE_FIELD_VEC_ENTRY("_HOSTNAME=", &hostname, &hostname_len),
PARSE_FIELD_VEC_ENTRY("SYSLOG_PID=", &fake_pid, &fake_pid_len),
PARSE_FIELD_VEC_ENTRY("SYSLOG_IDENTIFIER=", &identifier, &identifier_len),
@@ -421,6 +429,9 @@ static int output_short(
if (priority_len == 1 && *priority >= '0' && *priority <= '7')
p = *priority - '0';
+
+ audit = streq_ptr(transport, "audit");
+
if (mode == OUTPUT_SHORT_MONOTONIC)
r = output_timestamp_monotonic(f, j, monotonic);
else
@@ -475,7 +486,7 @@ static int output_short(
} else {
fputs(": ", f);
ellipsized |=
- print_multiline(f, n + 2, n_columns, flags, p,
+ print_multiline(f, n + 2, n_columns, flags, p, audit,
message, message_len,
highlight_shifted);
}
@@ -570,7 +581,9 @@ static int output_verbose(
(((length < PRINT_CHAR_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, NULL);
+ print_multiline(f, 4 + fieldlen + 1, 0, OUTPUT_FULL_WIDTH, 0, false,
+ c + 1, length - fieldlen - 1,
+ NULL);
fputs(off, f);
} else {
char bytes[FORMAT_BYTES_MAX];