summaryrefslogtreecommitdiff
path: root/man/sd_journal_query_unique.xml
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-01-27 18:59:29 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-01 22:42:33 +0100
commiteb86030ec0e53ef3834d1b230440e88fdf020e9d (patch)
treeee061f784523e84ead2766b653ffac923e1b9bc5 /man/sd_journal_query_unique.xml
parentb72190e90f0846956e609075fb9113dba9bc8f0f (diff)
sd-journal: add an API to enumerate known field names of the journal
This adds two new calls to get the list of all journal fields names currently in use. This is the low-level support to implement the feature requested in #2176 in a more optimized way.
Diffstat (limited to 'man/sd_journal_query_unique.xml')
-rw-r--r--man/sd_journal_query_unique.xml44
1 files changed, 25 insertions, 19 deletions
diff --git a/man/sd_journal_query_unique.xml b/man/sd_journal_query_unique.xml
index ac0e5f633f..dbff55c105 100644
--- a/man/sd_journal_query_unique.xml
+++ b/man/sd_journal_query_unique.xml
@@ -128,6 +128,11 @@
<para>Note that these functions currently are not influenced by
matches set with <function>sd_journal_add_match()</function> but
this might change in a later version of this software.</para>
+
+ <para>To enumerate all field names currently in use (and thus all suitable field parameters for
+ <function>sd_journal_query_unique()</function>), use the
+ <citerefentry><refentrytitle>sd_journal_enumerate_fields</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+ call.</para>
</refsect1>
<refsect1>
@@ -167,25 +172,25 @@
#include &lt;systemd/sd-journal.h&gt;
int main(int argc, char *argv[]) {
- sd_journal *j;
- const void *d;
- size_t l;
- int r;
-
- r = sd_journal_open(&amp;j, SD_JOURNAL_LOCAL_ONLY);
- if (r &lt; 0) {
- fprintf(stderr, "Failed to open journal: %s\n", strerror(-r));
- return 1;
- }
- r = sd_journal_query_unique(j, "_SYSTEMD_UNIT");
- if (r &lt; 0) {
- fprintf(stderr, "Failed to query journal: %s\n", strerror(-r));
- return 1;
- }
- SD_JOURNAL_FOREACH_UNIQUE(j, d, l)
- printf("%.*s\n", (int) l, (const char*) d);
- sd_journal_close(j);
- return 0;
+ sd_journal *j;
+ const void *d;
+ size_t l;
+ int r;
+
+ r = sd_journal_open(&amp;j, SD_JOURNAL_LOCAL_ONLY);
+ if (r &lt; 0) {
+ fprintf(stderr, "Failed to open journal: %s\n", strerror(-r));
+ return 1;
+ }
+ r = sd_journal_query_unique(j, "_SYSTEMD_UNIT");
+ if (r &lt; 0) {
+ fprintf(stderr, "Failed to query journal: %s\n", strerror(-r));
+ return 1;
+ }
+ SD_JOURNAL_FOREACH_UNIQUE(j, d, l)
+ printf("%.*s\n", (int) l, (const char*) d);
+ sd_journal_close(j);
+ return 0;
}</programlisting>
</refsect1>
@@ -198,6 +203,7 @@ int main(int argc, char *argv[]) {
<citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>sd_journal_enumerate_fields</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_journal_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>