test: Extend API test with three more phases
- with/without openlog() - setlogmask() - syslogp() API Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
38
test/api.c
38
test/api.c
@ -1,14 +1,48 @@
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "syslog.h"
|
||||
|
||||
int main(void)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *ident = NULL;
|
||||
char *msg = getenv("MSG");
|
||||
char c;
|
||||
int severity = LOG_NOTICE;
|
||||
int facility = LOG_CONSOLE;
|
||||
int v1 = 0;
|
||||
|
||||
if (!msg)
|
||||
return 1;
|
||||
|
||||
syslog(LOG_ERR, msg);
|
||||
while ((c = getopt(argc, argv, "i:lp")) != EOF) {
|
||||
switch (c) {
|
||||
case 'i':
|
||||
ident = optarg;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
setlogmask(LOG_UPTO(severity));
|
||||
severity = LOG_INFO;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
v1 = 1;
|
||||
facility = LOG_FTP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ident)
|
||||
openlog(ident, LOG_NOWAIT, facility);
|
||||
|
||||
if (v1)
|
||||
syslogp(severity, "MSGID", NULL, msg);
|
||||
else
|
||||
syslog(severity, msg);
|
||||
|
||||
if (ident)
|
||||
closelog();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user