2 * Copyright 2003-2015, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
14 main(int argc
, char **argv
)
16 openlog_team("SyslogTest", LOG_PID
, LOG_USER
);
18 log_team(LOG_ERR
, "this is %.", "a test");
20 int mask
= setlogmask_team(LOG_MASK(LOG_CRIT
));
21 printf("team mask == %d\n", mask
);
23 log_team(LOG_WARNING
, "this is a warning (hidden)");
24 log_team(LOG_CRIT
, "this is a critical condition (visible)");
26 setlogmask_team(mask
);
27 syslog(LOG_WARNING
, "thread warning (visible)");
28 syslog(LOG_CRIT
, "thread critical condition (visible)");
29 syslog(LOG_CRIT
, "thread critical condition (visible)");
31 setlogmask(LOG_MASK(LOG_WARNING
));
32 log_team(LOG_WARNING
| LOG_MAIL
, "2. this is a warning from the MAIL facility (visible)");
33 log_team(LOG_CRIT
, "2. this is a critical condition (visible)");
34 log_team(LOG_CRIT
, "2. this is a critical condition (visible)");
35 log_team(LOG_CRIT
, "2. this is a critical condition (visible)");
36 // test repeat message suppressing as well
38 openlog(NULL
, LOG_PERROR
, LOG_USER
);
39 syslog(LOG_WARNING
, "thread/perror warning (visible in stderr as well)");
40 syslog(LOG_CRIT
, "thread/perror critical condition (hidden)");
42 openlog(NULL
, LOG_CONS
| LOG_PID
, LOG_DAEMON
);
43 syslog(LOG_WARNING
, "thread/cons warning (visible in stderr only when there is no syslog_daemon)");
45 openlog("", 0, LOG_DAEMON
);
46 syslog(LOG_WARNING
, "thread warning without ident (visible)");
48 setlogmask(LOG_EMERG
);
50 // this should inherit the team log context on next logging entry
52 syslog(LOG_ALERT
, "now what are we doing here? (visible)");