]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
a4bcff5b LP |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2012 Lennart Poettering | |
6 | ||
7 | systemd is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU Lesser General Public License as published by | |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public License | |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
19 | ***/ | |
20 | ||
21 | #include <stdio.h> | |
22 | ||
a4bcff5b | 23 | #include "sd-journal.h" |
07630cea | 24 | |
cf0fbc49 | 25 | #include "journal-internal.h" |
07630cea | 26 | #include "log.h" |
763c7aa2 | 27 | #include "macro.h" |
a4bcff5b LP |
28 | |
29 | int main(int argc, char *argv[]) { | |
30 | unsigned n = 0; | |
4afd3348 | 31 | _cleanup_(sd_journal_closep) sd_journal*j = NULL; |
a4bcff5b LP |
32 | |
33 | log_set_max_level(LOG_DEBUG); | |
34 | ||
35 | assert_se(sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY) >= 0); | |
36 | ||
37 | assert_se(sd_journal_add_match(j, "_TRANSPORT=syslog", 0) >= 0); | |
38 | assert_se(sd_journal_add_match(j, "_UID=0", 0) >= 0); | |
39 | ||
40 | SD_JOURNAL_FOREACH_BACKWARDS(j) { | |
41 | const void *d; | |
42 | size_t l; | |
43 | ||
44 | assert_se(sd_journal_get_data(j, "MESSAGE", &d, &l) >= 0); | |
45 | ||
46 | printf("%.*s\n", (int) l, (char*) d); | |
47 | ||
313cefa1 | 48 | n++; |
a4bcff5b LP |
49 | if (n >= 10) |
50 | break; | |
51 | } | |
52 | ||
a4bcff5b LP |
53 | return 0; |
54 | } |