From: Lennart Poettering Date: Tue, 14 Jul 2020 09:25:18 +0000 (+0200) Subject: logs: when embedding catalog info in log output use a dash of color and unicode X-Git-Tag: v246-rc2~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ee5c1311eee10044ab1871dad4e5874ecc963a17;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index fee6ccdf2a1..899e894ab7e 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; }