summaryrefslogtreecommitdiff
path: root/debug.c
diff options
context:
space:
mode:
authorvenaas <venaas>2007-05-07 09:24:46 +0000
committervenaas <venaas@e88ac4ed-0b26-0410-9574-a7f39faa03bf>2007-05-07 09:24:46 +0000
commit02d56db68da9365e256f00cfd51227b485f96841 (patch)
tree5f99dcacb5b8d9d4924d4ba4e7595a0d3e01d941 /debug.c
parente103487ade654c8cb2bd20fcaadf97ee98faa737 (diff)
Can now specifiy syslog facility
git-svn-id: https://svn.testnett.uninett.no/radsecproxy/trunk@73 e88ac4ed-0b26-0410-9574-a7f39faa03bf
Diffstat (limited to 'debug.c')
-rw-r--r--debug.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/debug.c b/debug.c
index e5908e2..d7d333b 100644
--- a/debug.c
+++ b/debug.c
@@ -38,7 +38,14 @@ uint8_t debug_get_level() {
}
int debug_set_destination(char *dest) {
+ static const char *facstrings[] = { "LOG_DAEMON", "LOG_MAIL", "LOG_USER", "LOG_LOCAL0",
+ "LOG_LOCAL1", "LOG_LOCAL2", "LOG_LOCAL3", "LOG_LOCAL4",
+ "LOG_LOCAL5", "LOG_LOCAL6", "LOG_LOCAL7", NULL };
+ static const int facvals[] = { LOG_DAEMON, LOG_MAIL, LOG_USER, LOG_LOCAL0,
+ LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4,
+ LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7 };
extern int errno;
+ int i;
if (!strncasecmp(dest, "file:///", 8)) {
debug_file = fopen(dest + 7, "a");
@@ -48,12 +55,22 @@ int debug_set_destination(char *dest) {
setvbuf(debug_file, NULL, _IONBF, 0);
return 1;
}
- if (!strcasecmp(dest, "x-syslog://")) {
- debug_syslogfacility = LOG_DAEMON;
+ if (!strncasecmp(dest, "x-syslog://", 11)) {
+ dest += 11;
+ if (*dest) {
+ for (i = 0; facstrings[i]; i++)
+ if (!strcasecmp(dest, facstrings[i]))
+ break;
+ if (!facstrings[i])
+ debugx(1, DBG_ERR, "Unknown syslog facility %s", dest);
+ debug_syslogfacility = facvals[i];
+ } else
+ debug_syslogfacility = LOG_DAEMON;
openlog(debug_ident, LOG_PID, debug_syslogfacility);
return 1;
}
- return 0;
+ debug(DBG_ERR, "Unknown log destination, exiting %s", dest);
+ exit(1);
}
void debug_logit(uint8_t level, const char *format, va_list ap) {