]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/test-journal-enum.c
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / src / journal / test-journal-enum.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include <stdio.h>
4
5 #include "sd-journal.h"
6
7 #include "journal-internal.h"
8 #include "log.h"
9 #include "macro.h"
10
11 int main(int argc, char *argv[]) {
12 unsigned n = 0;
13 _cleanup_(sd_journal_closep) sd_journal*j = NULL;
14
15 log_set_max_level(LOG_DEBUG);
16
17 assert_se(sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY) >= 0);
18
19 assert_se(sd_journal_add_match(j, "_TRANSPORT=syslog", 0) >= 0);
20 assert_se(sd_journal_add_match(j, "_UID=0", 0) >= 0);
21
22 SD_JOURNAL_FOREACH_BACKWARDS(j) {
23 const void *d;
24 size_t l;
25
26 assert_se(sd_journal_get_data(j, "MESSAGE", &d, &l) >= 0);
27
28 printf("%.*s\n", (int) l, (char*) d);
29
30 n++;
31 if (n >= 10)
32 break;
33 }
34
35 return 0;
36 }