]>
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 | ||
7fb4d896 LP |
22 | #include <stdlib.h> |
23 | #include <unistd.h> | |
b070e7f3 | 24 | |
3ffd4af2 LP |
25 | #include "sd-journal.h" |
26 | ||
cbdca852 LP |
27 | #include "log.h" |
28 | ||
b070e7f3 | 29 | int main(int argc, char *argv[]) { |
1dfa7e79 LP |
30 | char huge[4096*1024]; |
31 | ||
cbdca852 LP |
32 | log_set_max_level(LOG_DEBUG); |
33 | ||
b070e7f3 LP |
34 | sd_journal_print(LOG_INFO, "piepapo"); |
35 | ||
36 | sd_journal_send("MESSAGE=foobar", | |
37 | "VALUE=%i", 7, | |
38 | NULL); | |
39 | ||
18c7ed18 LP |
40 | errno = ENOENT; |
41 | sd_journal_perror("Foobar"); | |
42 | ||
43 | sd_journal_perror(""); | |
44 | ||
1dfa7e79 LP |
45 | memset(huge, 'x', sizeof(huge)); |
46 | memcpy(huge, "HUGE=", 5); | |
47 | char_array_0(huge); | |
48 | ||
49 | sd_journal_send("MESSAGE=Huge field attached", | |
50 | huge, | |
51 | NULL); | |
52 | ||
d99ae53a LP |
53 | sd_journal_send("MESSAGE=uiui", |
54 | "VALUE=A", | |
55 | "VALUE=B", | |
56 | "VALUE=C", | |
57 | "SINGLETON=1", | |
58 | "OTHERVALUE=X", | |
59 | "OTHERVALUE=Y", | |
60 | "WITH_BINARY=this is a binary value \a", | |
61 | NULL); | |
62 | ||
7fb4d896 LP |
63 | syslog(LOG_NOTICE, "Hello World!"); |
64 | ||
65 | sd_journal_print(LOG_NOTICE, "Hello World"); | |
66 | ||
67 | sd_journal_send("MESSAGE=Hello World!", | |
68 | "MESSAGE_ID=52fb62f99e2c49d89cfbf9d6de5e3555", | |
69 | "PRIORITY=5", | |
70 | "HOME=%s", getenv("HOME"), | |
71 | "TERM=%s", getenv("TERM"), | |
72 | "PAGE_SIZE=%li", sysconf(_SC_PAGESIZE), | |
73 | "N_CPUS=%li", sysconf(_SC_NPROCESSORS_ONLN), | |
74 | NULL); | |
75 | ||
037ee337 | 76 | sleep(1); |
7fb4d896 | 77 | |
b070e7f3 LP |
78 | return 0; |
79 | } |