version 1.1.2.1, 2007/01/04 04:43:33
|
version 1.1.2.2, 2007/01/07 21:38:58
|
|
|
#include <syslog.h> | #include <syslog.h> |
#include <string.h> | #include <string.h> |
#include <stdarg.h> | #include <stdarg.h> |
|
#include "Strlcpy.h" |
|
#include "Strlcat.h" |
| |
static enum LogLevel _level = LL_INFORMATION; | static enum LogLevel _level = LL_INFORMATION; |
| |
|
|
LOG_NOTICE, /* LL_INFORMATION */ | LOG_NOTICE, /* LL_INFORMATION */ |
LOG_INFO, /* LL_TRACE */ | LOG_INFO, /* LL_TRACE */ |
}; | }; |
|
static const char* _prefix[] = |
|
{ |
|
"fatal", |
|
"severe", |
|
"warning", |
|
"information", |
|
"trace" |
|
}; |
|
char prefixedFormat[EXECUTOR_BUFFER_SIZE]; |
|
|
|
/* Prefix the format with the log level. */ |
|
|
|
Strlcpy(prefixedFormat, _prefix[(int)type], sizeof(prefixedFormat)); |
|
Strlcat(prefixedFormat, ": ", sizeof(prefixedFormat)); |
|
Strlcat(prefixedFormat, format, sizeof(prefixedFormat)); |
| |
/* This array maps Pegasus "log levels" to syslog priorities. */ | /* This array maps Pegasus "log levels" to syslog priorities. */ |
| |
|
|
{ | { |
va_list ap; | va_list ap; |
va_start(ap, format); | va_start(ap, format); |
vsyslog(_priorities[(int)type], format, ap); |
vsyslog(_priorities[(int)type], prefixedFormat, ap); |
va_end(ap); | va_end(ap); |
} | } |
} | } |