Add syslog based logging routines

Signed-off-by: Tushar Gohad <tushar.gohad@intel.com>
This commit is contained in:
Tushar Gohad 2014-07-18 04:42:38 -07:00
parent 901c37cee6
commit 33dce84728
4 changed files with 24 additions and 19 deletions

View File

@ -29,11 +29,11 @@ dnl Check for C library headers
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h \
string.h strings.h inttypes.h stdint.h ctype.h math.h iconv.h \
signal.h dlfcn.h pthread.h unistd.h limits.h errno.h)
AC_CHECK_FUNCS(malloc calloc realloc free)
signal.h dlfcn.h pthread.h unistd.h limits.h errno.h syslog.h)
AC_CHECK_FUNCS(malloc calloc realloc free openlog)
# Check for jerasure/gf_complete headers
AC_CHECK_HEADERS(jerasure.h cauchy.h galois.h liberation.h reed_sol.h gf_complete.h)
# Check for gf_complete headers
AC_CHECK_HEADERS(galois.h gf_complete.h)
# Enable this check when gf_complete is external
AC_CHECK_LIB([gf_complete], [gf_init_easy],

View File

@ -9,9 +9,6 @@
/* Define to 1 if you have the `calloc' function. */
#undef HAVE_CALLOC
/* Define to 1 if you have the <cauchy.h> header file. */
#undef HAVE_CAUCHY_H
/* Define to 1 if you have the <ctype.h> header file. */
#undef HAVE_CTYPE_H
@ -36,12 +33,6 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <jerasure.h> header file. */
#undef HAVE_JERASURE_H
/* Define to 1 if you have the <liberation.h> header file. */
#undef HAVE_LIBERATION_H
/* "Defined if gf-complete is installed" */
#undef HAVE_LIBGF_COMPLETE
@ -63,15 +54,15 @@
/* Support mmx instructions */
#undef HAVE_MMX
/* Define to 1 if you have the `openlog' function. */
#undef HAVE_OPENLOG
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
/* Define to 1 if you have the `realloc' function. */
#undef HAVE_REALLOC
/* Define to 1 if you have the <reed_sol.h> header file. */
#undef HAVE_REED_SOL_H
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
@ -114,6 +105,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H

View File

@ -32,7 +32,7 @@
#include "erasurecode_backend.h"
#include "erasurecode_stdinc.h"
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~= Logging =~==~=*=~==~=*=~==~=*=~==~=*=~== */
#if __STDC_VERSION__ < 199901L
#if __GNUC__ >= 2
@ -42,8 +42,16 @@
#endif
#endif
#define log_error(str) \
fprintf(stderr, "%s:%d (%s): %s\n", __FILE__, __LINE__, __func__, str)
#define _LOG1(level, ...) \
syslog (level, __VA_ARGS__)
#define _LOG2(level, ...) \
syslog (level, "%s:%d:%s\n", __FILE__, __LINE__, __VA_ARGS__)
#define log_info(str, ...) _LOG1(LOG_INFO, str)
#define log_warn(str, ...) _LOG1(LOG_WARNING, str)
#define log_error(str, ...) _LOG1(LOG_ERR, str)
#define log_debug(str, ...) _LOG2(LOG_DEBUG, str)
/* ==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~==~=*=~== */

View File

@ -27,6 +27,9 @@
#include "config.h"
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif