X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Flogs-show.c;h=cb93761bd19d83f191229932957ee9b00d1e5aa0;hb=d4205751d4643c272059a3728045929dd0e5e800;hp=36cce73550f45b4dd18a00ad42a299ccae108934;hpb=d99ae53a7327e1520ea4b9a3408c2d7f938c4b37;p=elogind.git diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 36cce7355..cb93761bd 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -34,6 +34,26 @@ #define PRINT_THRESHOLD 128 #define JSON_THRESHOLD 4096 +static int print_catalog(FILE *f, sd_journal *j) { + int r; + _cleanup_free_ char *t = NULL, *z = NULL; + + + r = sd_journal_get_catalog(j, &t); + if (r < 0) + return r; + + z = strreplace(strstrip(t), "\n", "\n-- "); + if (!z) + return log_oom(); + + fputs("-- ", f); + fputs(z, f); + fputc('\n', f); + + return 0; +} + static int parse_field(const void *data, size_t length, const char *field, char **target, size_t *target_size) { size_t fl, nl; void *buf; @@ -265,6 +285,9 @@ static int output_short( } else fputs("\n", f); + if (flags & OUTPUT_CATALOG) + print_catalog(f, j); + return 0; } @@ -322,6 +345,9 @@ static int output_verbose( fprintf(f, "\t%.*s\n", (int) length, (const char*) data); } + if (flags & OUTPUT_CATALOG) + print_catalog(f, j); + return 0; }