]>
Commit | Line | Data |
---|---|---|
b070e7f3 LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2011 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
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 | |
b070e7f3 LP |
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 | |
5430f7f2 | 16 | Lesser General Public License for more details. |
b070e7f3 | 17 | |
5430f7f2 | 18 | You should have received a copy of the GNU Lesser General Public License |
b070e7f3 LP |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
20 | ***/ | |
21 | ||
22 | #include <systemd/sd-journal.h> | |
7fb4d896 LP |
23 | #include <stdlib.h> |
24 | #include <unistd.h> | |
b070e7f3 | 25 | |
cbdca852 LP |
26 | #include "log.h" |
27 | ||
b070e7f3 | 28 | int main(int argc, char *argv[]) { |
1dfa7e79 LP |
29 | char huge[4096*1024]; |
30 | ||
cbdca852 LP |
31 | log_set_max_level(LOG_DEBUG); |
32 | ||
b070e7f3 LP |
33 | sd_journal_print(LOG_INFO, "piepapo"); |
34 | ||
35 | sd_journal_send("MESSAGE=foobar", | |
36 | "VALUE=%i", 7, | |
37 | NULL); | |
38 | ||
18c7ed18 LP |
39 | errno = ENOENT; |
40 | sd_journal_perror("Foobar"); | |
41 | ||
42 | sd_journal_perror(""); | |
43 | ||
1dfa7e79 LP |
44 | memset(huge, 'x', sizeof(huge)); |
45 | memcpy(huge, "HUGE=", 5); | |
46 | char_array_0(huge); | |
47 | ||
48 | sd_journal_send("MESSAGE=Huge field attached", | |
49 | huge, | |
50 | NULL); | |
51 | ||
d99ae53a LP |
52 | sd_journal_send("MESSAGE=uiui", |
53 | "VALUE=A", | |
54 | "VALUE=B", | |
55 | "VALUE=C", | |
56 | "SINGLETON=1", | |
57 | "OTHERVALUE=X", | |
58 | "OTHERVALUE=Y", | |
59 | "WITH_BINARY=this is a binary value \a", | |
60 | NULL); | |
61 | ||
7fb4d896 LP |
62 | syslog(LOG_NOTICE, "Hello World!"); |
63 | ||
64 | sd_journal_print(LOG_NOTICE, "Hello World"); | |
65 | ||
66 | sd_journal_send("MESSAGE=Hello World!", | |
67 | "MESSAGE_ID=52fb62f99e2c49d89cfbf9d6de5e3555", | |
68 | "PRIORITY=5", | |
69 | "HOME=%s", getenv("HOME"), | |
70 | "TERM=%s", getenv("TERM"), | |
71 | "PAGE_SIZE=%li", sysconf(_SC_PAGESIZE), | |
72 | "N_CPUS=%li", sysconf(_SC_NPROCESSORS_ONLN), | |
73 | NULL); | |
74 | ||
75 | sleep(10); | |
76 | ||
b070e7f3 LP |
77 | return 0; |
78 | } |