Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -1,10 +1,10 @@ APPFS_VERSION = 1.14 CC = gcc PKG_CONFIG = pkg-config FUSE_CFLAGS = $(shell $(PKG_CONFIG) --cflags fuse) -CFLAGS_DEBUG = -Wall -g3 -ggdb3 -DDEBUG=1 -UNDEBUG -O0 -DAPPFS_EXIT_PATH=1 -DAPPFS_DEBUG_FD=stderr +CFLAGS_DEBUG = -Wall -g3 -ggdb3 -DDEBUG=1 -UNDEBUG -O0 -DAPPFS_EXIT_PATH=1 CFLAGS_RELEASE = -Wall -UDEBUG -DNDEBUG=1 -O3 ifneq ($(APPFS_DEBUG_BUILD),1) CFLAGS += $(FUSE_CFLAGS) $(TCL_CFLAGS) $(CFLAGS_RELEASE) else CFLAGS += $(FUSE_CFLAGS) $(TCL_CFLAGS) $(CFLAGS_DEBUG) Index: appfsd.c ================================================================== --- appfsd.c +++ appfsd.c @@ -45,24 +45,24 @@ #endif /* Debugging macros */ #ifdef DEBUG FILE *appfs_debug_fd = NULL; - -#ifndef APPFS_DEBUG_FD -# ifdef APPFS_DEBUG_FILE -# define APPFS_DEBUG_FD fopen(APPFS_DEBUG_FILE, "a") -# else -# define APPFS_DEBUG_FD fopen("/tmp/appfsd.log", "a") -# endif -#endif - #define APPFS_DEBUG(x...) { \ char buf[8192]; \ int bufoff = 0; \ + char *appfs_debug_file = NULL; \ if (appfs_debug_fd == NULL) { \ - appfs_debug_fd = APPFS_DEBUG_FD; \ + appfs_debug_file = getenv("APPFS_DEBUG_FILE"); \ + if (appfs_debug_file == NULL) { \ + appfs_debug_file = "stderr"; \ + }; \ + if (strcmp(appfs_debug_file, "stderr") == 0) { \ + appfs_debug_fd = stderr; \ + } else { \ + appfs_debug_fd = fopen(appfs_debug_file, "a"); \ + }; \ }; \ if (appfs_debug_fd == NULL) { appfs_debug_fd = stderr; } \ bufoff = snprintf(buf, sizeof(buf), "[debug] [t=%llx] %s:%i:%s: ", (unsigned long long) pthread_self(), __FILE__, __LINE__, __func__); \ if (bufoff < sizeof(buf)) { \ bufoff += snprintf(buf + bufoff, sizeof(buf) - bufoff, x); \