Jelajahi Sumber

Merge branch 'debug-buf'

* debug-buf:
  * Change alias names in ContextNote
  * Don't printf() debug statements unless running in debug more
  * Use ContextNote in sdprintf()
Bryan Drewery 16 tahun lalu
induk
melakukan
98ebc07ae9
2 mengubah file dengan 4 tambahan dan 7 penghapusan
  1. 2 5
      src/debug.c
  2. 2 2
      src/debug.h

+ 2 - 5
src/debug.c

@@ -104,18 +104,15 @@ void sdprintf (const char *format, ...)
 
   remove_crlf(s);
 
-  simple_snprintf(get_buf[current_get_buf], sizeof(get_buf[current_get_buf]), "dbg: %s", s);
-  get_buf_inc();
+  ContextNote("dbg", s);
 
-#ifdef DEBUG
   if (sdebug) {
-#endif
     if (!backgrd)
       dprintf(DP_STDOUT, "[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1));
     else
       printf("[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1));
-#ifdef DEBUG
   }
+#ifdef DEBUG
   logfile(LOG_DEBUG, s);
 #endif
 }

+ 2 - 2
src/debug.h

@@ -13,8 +13,8 @@
   get_buf_inc(); \
 } while (0)
 
-#define ContextNote(from, buf) do { \
-  simple_snprintf(get_buf[current_get_buf], sizeof(get_buf[current_get_buf]), "%s: %s", from, buf); \
+#define ContextNote(_from, _buf) do { \
+  simple_snprintf(get_buf[current_get_buf], sizeof(get_buf[current_get_buf]), "%s: %s", _from, _buf); \
   get_buf_inc(); \
 } while(0)