forked from includeos/IncludeOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyslog_example.c
More file actions
46 lines (28 loc) · 1.46 KB
/
Copy pathsyslog_example.c
File metadata and controls
46 lines (28 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <syslog.h>
int main()
{
/* ------------------------- POSIX syslog on lubuntu ------------------------- */
int invalid_priority = -1;
syslog(invalid_priority, "Invalid %d", invalid_priority);
invalid_priority = 10;
syslog(invalid_priority, "Invalid %d", invalid_priority);
invalid_priority = 55;
syslog(invalid_priority, "Invalid %d", invalid_priority);
syslog(LOG_INFO, "(Info) No open has been called prior to this");
syslog(LOG_NOTICE, "(Notice) Program created with two arguments: %s and %s", "one", "two");
openlog("Prepended message", LOG_CONS | LOG_NDELAY, LOG_MAIL);
syslog(LOG_ERR, "(Err) Log after prepended message with one argument: %d", 44);
syslog(LOG_WARNING, "(Warning) Log number two after openlog set prepended message");
closelog();
syslog(LOG_WARNING, "(Warning) Log after closelog with three arguments. One is %u, another is %s, a third is %d", 33, "this", 4011);
openlog("Second prepended message", LOG_PID | LOG_CONS, LOG_USER);
syslog(LOG_EMERG, "This is a test of an emergency log. You might need to stop the program manually.");
syslog(LOG_ALERT, "Alert log with the m argument: %m");
closelog();
syslog(LOG_CRIT, "Critical after cleared prepended message (closelog has been called)");
closelog();
openlog("Open after close prepended message", LOG_CONS, LOG_MAIL);
syslog(LOG_INFO, "Info after openlog with both m: %m and two hex arguments: 0x%x and 0x%x", 100, 50);
closelog();
return 0;
}