]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/test-journal-enum.c
3f00200adfc3cb7683054fd8a159cad244fa0742
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 Copyright 2012 Lennart Poettering
8 #include "sd-journal.h"
10 #include "journal-internal.h"
14 int main(int argc
, char *argv
[]) {
16 _cleanup_(sd_journal_closep
) sd_journal
*j
= NULL
;
18 log_set_max_level(LOG_DEBUG
);
20 assert_se(sd_journal_open(&j
, SD_JOURNAL_LOCAL_ONLY
) >= 0);
22 assert_se(sd_journal_add_match(j
, "_TRANSPORT=syslog", 0) >= 0);
23 assert_se(sd_journal_add_match(j
, "_UID=0", 0) >= 0);
25 SD_JOURNAL_FOREACH_BACKWARDS(j
) {
29 assert_se(sd_journal_get_data(j
, "MESSAGE", &d
, &l
) >= 0);
31 printf("%.*s\n", (int) l
, (char*) d
);