diff --git a/config.h b/config.h index 35be6f961fa86cb6c3ae54ce75a1391a4529ac16..671c0eb88e837098473b7e2bd100f9ab3bf4b27f 100644 --- a/config.h +++ b/config.h @@ -1,6 +1,8 @@ #ifndef CONFIG_H # define CONFIG_H +# define DEBUG_OUTPUT 0 // change to 1 to enable debugging + #ifdef __MINGW32__ # include <stdint.h> diff --git a/gck-rpc-daemon-standalone.c b/gck-rpc-daemon-standalone.c index 5f30514dbe10aeb8f63caf62baf4590dd3b2105a..88c5c395ed38d0cc931d223543fdf1ef65d2ba81 100644 --- a/gck-rpc-daemon-standalone.c +++ b/gck-rpc-daemon-standalone.c @@ -36,6 +36,8 @@ #include <dlfcn.h> #include <pthread.h> +#include <syslog.h> + #ifdef __MINGW32__ # include <winsock2.h> #endif @@ -76,6 +78,8 @@ int main(int argc, char *argv[]) if (argc != 2 && argc != 3) usage(); + openlog("pkcs11-proxy",LOG_CONS|LOG_PID,LOG_DAEMON); + /* Load the library */ module = dlopen(argv[1], RTLD_NOW); if (!module) { diff --git a/gck-rpc-dispatch.c b/gck-rpc-dispatch.c index 6b0687d44f2ff7ea6128ecbcc5d5aac7eba1a7eb..4f31e95981a9e18b8121f3ef644908371637e246 100644 --- a/gck-rpc-dispatch.c +++ b/gck-rpc-dispatch.c @@ -48,6 +48,7 @@ #include <unistd.h> #include <errno.h> #include <stdio.h> +#include <syslog.h> /* Where we dispatch the calls to */ static CK_FUNCTION_LIST_PTR pkcs11_module = NULL; @@ -83,8 +84,9 @@ static pthread_mutex_t pkcs11_dispatchers_mutex = PTHREAD_MUTEX_INITIALIZER; /* ----------------------------------------------------------------------------- * LOGGING and DEBUGGING */ -#undef DEBUG_OUTPUT +#ifndef DEBUG_OUTPUT #define DEBUG_OUTPUT 1 +#endif #if DEBUG_OUTPUT #define debug(x) gck_rpc_debug x #else @@ -101,7 +103,11 @@ void gck_rpc_log(const char *msg, ...) va_list ap; va_start(ap, msg); +#if DEBUG_OUTPUT vfprintf(stderr, msg, ap); +#else + vsyslog(LOG_INFO,msg,ap); +#endif printf("\n"); va_end(ap); }