From b4d636b2af1733641254de508b2d9e14d208611f Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 11 Apr 2014 10:38:56 +1000 Subject: [PATCH] Add based logging macros --- configure.ac | 2 +- src/libckpool.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 33dc2984..fcdb312a 100644 --- a/configure.ac +++ b/configure.ac @@ -33,7 +33,7 @@ PKG_PROG_PKG_CONFIG() AC_CHECK_HEADERS(stdio.h stdlib.h fcntl.h sys/time.h unistd.h) AC_CHECK_HEADERS(ctype.h errno.h byteswap.h string.h time.h) -AC_CHECK_HEADERS(endian.h sys/endian.h arpa/inet.h) +AC_CHECK_HEADERS(endian.h sys/endian.h arpa/inet.h syslog.h) AC_CHECK_HEADERS(alloca.h pthread.h stdio.h math.h) AC_CHECK_HEADERS(sys/types.h sys/socket.h) AC_CHECK_HEADERS(stdint.h netinet/in.h netinet/tcp.h) diff --git a/src/libckpool.h b/src/libckpool.h index d36bdb22..51f5cffb 100644 --- a/src/libckpool.h +++ b/src/libckpool.h @@ -16,6 +16,7 @@ #include #include #include +#include #define mutex_lock(_lock) _mutex_lock(_lock, __FILE__, __func__, __LINE__) #define mutex_unlock_noyield(_lock) _mutex_unlock_noyield(_lock, __FILE__, __func__, __LINE__) @@ -43,6 +44,20 @@ #define ck_runlock(_lock) _ck_runlock(_lock, __FILE__, __func__, __LINE__) #define ck_wunlock(_lock) _ck_wunlock(_lock, __FILE__, __func__, __LINE__) +/* Placeholders for when we have more comprehensive logging facilities */ +#define LOGERR(fmt, ...) do { \ + if (fmt) { \ + fprintf(stderr, fmt, ##__VA_ARGS__); \ + fprintf(stderr, "\n"); \ + fflush(stderr); \ + } \ +} while (0) + +#define LOGWARNING(fmt, ...) LOGERR(fmt, ##__VA_ARGS__) +#define LOGNOTICE(fmt, ...) LOGERR(fmt, ##__VA_ARGS__) +#define LOGINFO(fmt, ...) LOGERR(fmt, ##__VA_ARGS__) +#define LOGDEBUG(fmt, ...) LOGERR(fmt, ##__VA_ARGS__) + #define IN_FMT_FFL " in %s %s():%d" #define quitfrom(status, _file, _func, _line, fmt, ...) do { \ if (fmt) { \