summaryrefslogtreecommitdiff
path: root/src/shared/logs-show.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-11-15 23:03:31 +0100
committerLennart Poettering <lennart@poettering.net>2012-11-15 23:09:07 +0100
commitd4205751d4643c272059a3728045929dd0e5e800 (patch)
treec9931806e99d42789fc5ce3fc03e17285b9bb208 /src/shared/logs-show.c
parent59f432ea6d6d441d0af7c76c37e80730c8df473a (diff)
journal: implement message catalog
The message catalog can be used to attach short help texts to log lines, keyed by their MESSAGE_ID= fields. This is useful to help the administrator understand the context and cause of a message, find possible solutions and find further related documentation. Since this is keyed off MESSAGE_ID= this will only work for native journal messages. The message catalog supports i18n, and is useful to augment english language system messages with explanations in the local language. This commit only includes short explanatory messages for a few example message IDs, we'll add more complete documentation for the relevant systemd messages later on.
Diffstat (limited to 'src/shared/logs-show.c')
-rw-r--r--src/shared/logs-show.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 36cce73550..cb93761bd1 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;
}