Check-in [e722919c08]
Overview
Comment:Improve debug logging flexibility
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:e722919c08c82bb11e41b519411c4d02a9e22ac6
User & Date: rkeene on 2020-05-12 15:09:18
Other Links: manifest | tags
Context
2020-05-12
15:09
AppFS 1.14 check-in: 567832addb user: rkeene tags: trunk, 1.14
15:09
Improve debug logging flexibility check-in: e722919c08 user: rkeene tags: trunk
15:08
Commit [7241c0986c] broke writing because error messages were checked, fix the check and fix writing check-in: b5b196f3f3 user: rkeene tags: trunk
Changes

Modified Makefile from [bc18beb7d4] to [27f21bab36].

     1      1   APPFS_VERSION  = 1.12
     2      2   CC             = gcc
     3      3   PKG_CONFIG     = pkg-config
     4      4   FUSE_CFLAGS    = $(shell $(PKG_CONFIG) --cflags fuse)
     5         -CFLAGS_DEBUG   = -Wall -g3 -ggdb3 -DDEBUG=1 -UNDEBUG -O0 -DAPPFS_EXIT_PATH=1
            5  +CFLAGS_DEBUG   = -Wall -g3 -ggdb3 -DDEBUG=1 -UNDEBUG -O0 -DAPPFS_EXIT_PATH=1 -DAPPFS_DEBUG_FD=stderr
     6      6   CFLAGS_RELEASE = -Wall -UDEBUG -DNDEBUG=1 -O3
     7      7   ifneq ($(APPFS_DEBUG_BUILD),1)
     8      8   CFLAGS         += $(FUSE_CFLAGS) $(TCL_CFLAGS) $(CFLAGS_RELEASE)
     9      9   else
    10     10   CFLAGS         += $(FUSE_CFLAGS) $(TCL_CFLAGS) $(CFLAGS_DEBUG)
    11     11   endif
    12     12   LDFLAGS        += $(TCL_LDFLAGS)

Modified appfsd.c from [0494c72e1d] to [b81dc3008d].

    43     43   #ifndef APPFS_CACHEDIR
    44     44   #define APPFS_CACHEDIR "/var/cache/appfs"
    45     45   #endif
    46     46   
    47     47   /* Debugging macros */
    48     48   #ifdef DEBUG
    49     49   FILE *appfs_debug_fd = NULL;
           50  +
           51  +#ifndef APPFS_DEBUG_FD
           52  +#  ifdef APPFS_DEBUG_FILE
           53  +#    define APPFS_DEBUG_FD fopen(APPFS_DEBUG_FILE, "a")
           54  +#  else
           55  +#    define APPFS_DEBUG_FD fopen("/tmp/appfsd.log", "a")
           56  +#  endif
           57  +#endif
           58  +
    50     59   #define APPFS_DEBUG(x...) { \
    51     60   	char buf[8192]; \
    52     61   	int bufoff = 0; \
    53     62   	if (appfs_debug_fd == NULL) { \
    54         -		appfs_debug_fd = fopen("/tmp/appfsd.log", "a"); \
           63  +		appfs_debug_fd = APPFS_DEBUG_FD; \
    55     64   	}; \
    56     65   	if (appfs_debug_fd == NULL) { appfs_debug_fd = stderr; } \
    57     66   	bufoff = snprintf(buf, sizeof(buf), "[debug] [t=%llx] %s:%i:%s: ", (unsigned long long) pthread_self(), __FILE__, __LINE__, __func__); \
    58     67   	if (bufoff < sizeof(buf)) { \
    59     68   		bufoff += snprintf(buf + bufoff, sizeof(buf) - bufoff, x); \
    60     69   	}; \
    61     70   	if (bufoff < sizeof(buf)) { \
................................................................................
  2367   2376   
  2368   2377   	/*
  2369   2378   	 * Skip passed program name
  2370   2379   	 */
  2371   2380   	if (argc == 0 || argv == NULL) {
  2372   2381   		return(1);
  2373   2382   	}
         2383  +for (i = 0; i < argc; i++) {
         2384  +//	printf("argv[%i] = \"%s\"\n", i, argv[i]);
         2385  +}
  2374   2386   
  2375   2387   	argv0 = argv[0];
  2376   2388   
  2377   2389   	argc--;
  2378   2390   	argv++;
  2379   2391   
  2380   2392   	/*