1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 #include "sd-journal.h"
7 #include "journal-internal.h"
12 int main(int argc
, char *argv
[]) {
14 _cleanup_(sd_journal_closep
) sd_journal
*j
= NULL
;
16 test_setup_logging(LOG_DEBUG
);
18 assert_se(sd_journal_open(&j
, SD_JOURNAL_LOCAL_ONLY
| SD_JOURNAL_ASSUME_IMMUTABLE
) >= 0);
20 assert_se(sd_journal_add_match(j
, "_TRANSPORT=syslog", 0) >= 0);
21 assert_se(sd_journal_add_match(j
, "_UID=0", 0) >= 0);
23 SD_JOURNAL_FOREACH_BACKWARDS(j
) {
27 assert_se(sd_journal_get_data(j
, "MESSAGE", &d
, &l
) >= 0);
29 printf("%.*s\n", (int) l
, (char*) d
);