summaryrefslogtreecommitdiff
path: root/src/shared/logs-show.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-07-14 11:25:18 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-07-15 09:32:03 +0200
commitee5c1311eee10044ab1871dad4e5874ecc963a17 (patch)
tree379cbe7a8a63ac98fdb49da054e04b65a0db6df8 /src/shared/logs-show.c
parenta996ead6a205e0c459841417499edeb716c0928a (diff)
downloadsystemd-ee5c1311eee10044ab1871dad4e5874ecc963a17.tar.gz
logs: when embedding catalog info in log output use a dash of color and unicode
let's separate things out a bit, to make it easier to discern log output and catalog data. catalog data is now colored green (which is a color we don't use for log data currently), and prefixed with a block shade.
Diffstat (limited to 'src/shared/logs-show.c')
-rw-r--r--src/shared/logs-show.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index fee6ccdf2a..899e894ab7 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -50,6 +50,7 @@
static int print_catalog(FILE *f, sd_journal *j) {
_cleanup_free_ char *t = NULL, *z = NULL;
+ const char *newline, *prefix;
int r;
assert(j);
@@ -60,13 +61,31 @@ static int print_catalog(FILE *f, sd_journal *j) {
if (r < 0)
return log_error_errno(r, "Failed to find catalog entry: %m");
- z = strreplace(strstrip(t), "\n", "\n-- ");
+ if (is_locale_utf8())
+ prefix = strjoina(special_glyph(SPECIAL_GLYPH_LIGHT_SHADE), special_glyph(SPECIAL_GLYPH_LIGHT_SHADE));
+ else
+ prefix = "--";
+
+ if (colors_enabled())
+ newline = strjoina(ANSI_NORMAL "\n" ANSI_GREY, prefix, ANSI_NORMAL " " ANSI_GREEN);
+ else
+ newline = strjoina("\n", prefix, " ");
+
+ z = strreplace(strstrip(t), "\n", newline);
if (!z)
return log_oom();
- fputs("-- ", f);
+ if (colors_enabled())
+ fprintf(f, ANSI_GREY "%s" ANSI_NORMAL " " ANSI_GREEN, prefix);
+ else
+ fprintf(f, "%s ", prefix);
+
fputs(z, f);
- fputc('\n', f);
+
+ if (colors_enabled())
+ fputs(ANSI_NORMAL "\n", f);
+ else
+ fputc('\n', f);
return 1;
}