diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-10-18 03:29:19 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-10-18 03:35:18 +0200 |
commit | 3c1668da6202f1ead3d4d3981b89e9da1a0e98e3 (patch) | |
tree | d4e2785f1dac02c19797373bb4342354e1958e9d /src/systemd/sd-journal.h | |
parent | 86b2e20a5e5abf222fb81edcb5d58d012e35cbaa (diff) | |
download | systemd-3c1668da6202f1ead3d4d3981b89e9da1a0e98e3.tar.gz |
journal: add ability to list values a specified field can take in all entries of the journal
The new 'unique' API allows listing all unique field values that a field
specified by a field name can take in all entries of the journal. This
allows answering queries such as "What units logged to the journal?",
"What hosts have logged into the journal?", "Which boot IDs have logged
into the journal?".
Ultimately this allows implementation of tools similar to lastlog based
on journal data.
Note that listing these field values will not work for journal files
created with older journald, as the field values are not indexed in
older files.
Diffstat (limited to 'src/systemd/sd-journal.h')
-rw-r--r-- | src/systemd/sd-journal.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/systemd/sd-journal.h b/src/systemd/sd-journal.h index 9a2aab923a..55281b1346 100644 --- a/src/systemd/sd-journal.h +++ b/src/systemd/sd-journal.h @@ -70,12 +70,20 @@ int sd_journal_stream_fd(const char *identifier, int priority, int level_prefix) typedef struct sd_journal sd_journal; +/* Open flags */ enum { SD_JOURNAL_LOCAL_ONLY = 1, SD_JOURNAL_RUNTIME_ONLY = 2, SD_JOURNAL_SYSTEM_ONLY = 4 }; +/* Wakeup event types */ +enum { + SD_JOURNAL_NOP, + SD_JOURNAL_APPEND, + SD_JOURNAL_INVALIDATE +}; + int sd_journal_open(sd_journal **ret, int flags); int sd_journal_open_directory(sd_journal **ret, const char *path, int flags); void sd_journal_close(sd_journal *j); @@ -111,15 +119,9 @@ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, const sd_id128_t boot_id int sd_journal_get_usage(sd_journal *j, uint64_t *bytes); -/* int sd_journal_query_unique(sd_journal *j, const char *field); /\* missing *\/ */ -/* int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_t *l); /\* missing *\/ */ -/* void sd_journal_restart_unique(sd_journal *j); /\* missing *\/ */ - -enum { - SD_JOURNAL_NOP, - SD_JOURNAL_APPEND, - SD_JOURNAL_INVALIDATE -}; +int sd_journal_query_unique(sd_journal *j, const char *field); +int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_t *l); +void sd_journal_restart_unique(sd_journal *j); int sd_journal_get_fd(sd_journal *j); int sd_journal_process(sd_journal *j); @@ -136,8 +138,8 @@ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec); #define SD_JOURNAL_FOREACH_DATA(j, data, l) \ for (sd_journal_restart_data(j); sd_journal_enumerate_data((j), &(data), &(l)) > 0; ) -/* #define SD_JOURNAL_FOREACH_UNIQUE(j, data, l) \ */ -/* for (sd_journal_restart_unique(j); sd_journal_enumerate_data((j), &(data), &(l)) > 0; ) */ +#define SD_JOURNAL_FOREACH_UNIQUE(j, data, l) \ + for (sd_journal_restart_unique(j); sd_journal_enumerate_unique((j), &(data), &(l)) > 0; ) #ifdef __cplusplus } |