Browse Source

Add based logging macros

master
Con Kolivas 11 years ago
parent
commit
b4d636b2af
  1. 2
      configure.ac
  2. 15
      src/libckpool.h

2
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(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(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(alloca.h pthread.h stdio.h math.h)
AC_CHECK_HEADERS(sys/types.h sys/socket.h) AC_CHECK_HEADERS(sys/types.h sys/socket.h)
AC_CHECK_HEADERS(stdint.h netinet/in.h netinet/tcp.h) AC_CHECK_HEADERS(stdint.h netinet/in.h netinet/tcp.h)

15
src/libckpool.h

@ -16,6 +16,7 @@
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <stdio.h> #include <stdio.h>
#include <syslog.h>
#define mutex_lock(_lock) _mutex_lock(_lock, __FILE__, __func__, __LINE__) #define mutex_lock(_lock) _mutex_lock(_lock, __FILE__, __func__, __LINE__)
#define mutex_unlock_noyield(_lock) _mutex_unlock_noyield(_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_runlock(_lock) _ck_runlock(_lock, __FILE__, __func__, __LINE__)
#define ck_wunlock(_lock) _ck_wunlock(_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 IN_FMT_FFL " in %s %s():%d"
#define quitfrom(status, _file, _func, _line, fmt, ...) do { \ #define quitfrom(status, _file, _func, _line, fmt, ...) do { \
if (fmt) { \ if (fmt) { \

Loading…
Cancel
Save