commit
62af47a2f6
@ -40,6 +40,9 @@ void capwap_logging_init() {
|
||||
#ifdef CAPWAP_MULTITHREADING_ENABLE
|
||||
capwap_lock_init(&l_loglock);
|
||||
#endif
|
||||
#ifdef LOG_TO_SYSLOG
|
||||
openlog("capwap", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -47,6 +50,9 @@ void capwap_logging_close() {
|
||||
#ifdef CAPWAP_MULTITHREADING_ENABLE
|
||||
capwap_lock_destroy(&l_loglock);
|
||||
#endif
|
||||
#ifdef LOG_TO_SYSLOG
|
||||
closelog();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* */
|
||||
@ -107,6 +113,16 @@ void capwap_logging_disable_console(void) {
|
||||
|
||||
/* */
|
||||
#ifdef ENABLE_LOGGING
|
||||
void __log_syslog(int level, const char* format, ...)
|
||||
{
|
||||
int errsv = errno;
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vsyslog(level, format, args);
|
||||
va_end(args);
|
||||
errno = errsv;
|
||||
}
|
||||
|
||||
void __log_printf(int level, const char* format, ...)
|
||||
{
|
||||
int errsv = errno;
|
||||
@ -143,8 +159,8 @@ void __log_printf(int level, const char* format, ...)
|
||||
|
||||
void __log_hexdump(int level, const char *title, const unsigned char *data, size_t len)
|
||||
{
|
||||
int errsv = errno;
|
||||
char prefix[256];
|
||||
int errsv = errno;
|
||||
char prefix[256];
|
||||
|
||||
if (level > logginglevel)
|
||||
return;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define __CAPWAP_LOGGING_HEADER__
|
||||
|
||||
#include <syslog.h>
|
||||
#define LOG_TO_SYSLOG
|
||||
|
||||
/* Logging level */
|
||||
#define LOG_NONE -1
|
||||
@ -23,6 +24,8 @@ void capwap_logging_disable_console(void);
|
||||
void __log_printf(int level, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
void __log_hexdump(int level, const char *title, const unsigned char *data, size_t len);
|
||||
void __log_syslog(int level, const char* format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
|
||||
#ifdef DISABLE_LOGGING_DEBUG
|
||||
|
||||
@ -39,11 +42,15 @@ void __log_hexdump(int level, const char *title, const unsigned char *data, size
|
||||
|
||||
#else
|
||||
|
||||
#ifdef LOG_TO_SYSLOG
|
||||
#define log_printf(level, f, args...) \
|
||||
__log_syslog((level), (f), ##args)
|
||||
#else
|
||||
#define log_printf(level, f, args...) \
|
||||
__log_printf((level), (f), ##args)
|
||||
#endif
|
||||
#define log_hexdump(level, title, data, len) \
|
||||
__log_hexdump((level), (title), (data), (len))
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user