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