Fix debugging verbosity in radclient
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 2 Jun 2014 16:46:18 +0000 (17:46 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 2 Jun 2014 16:46:18 +0000 (17:46 +0100)
src/include/radclient.h
src/main/radclient.c

index 1764225..67d14b7 100644 (file)
@@ -33,19 +33,19 @@ extern "C" {
  *     Logging macros
  */
  #undef DEBUG
-#define DEBUG(fmt, ...)                if (do_output && (fr_debug_flag > 0)) fprintf(fr_log_fp, fmt "\n", ## __VA_ARGS__)
+#define DEBUG(fmt, ...)                if (do_output && (rc_debug_flag > 0)) fprintf(fr_log_fp, fmt "\n", ## __VA_ARGS__)
 #undef DEBUG2
-#define DEBUG2(fmt, ...)       if (do_output && (fr_debug_flag > 1)) fprintf(fr_log_fp, fmt "\n", ## __VA_ARGS__)
+#define DEBUG2(fmt, ...)       if (do_output && (rc_debug_flag > 1)) fprintf(fr_log_fp, fmt "\n", ## __VA_ARGS__)
 
 
 #define ERROR(fmt, ...)                if (do_output) fr_perror("radclient: " fmt, ## __VA_ARGS__)
 
-#define RDEBUG_ENABLED()       (do_output && (fr_debug_flag > 0))
-#define RDEBUG_ENABLED2()      (do_output && (fr_debug_flag > 1))
+#define RDEBUG_ENABLED()       (do_output && (rc_debug_flag > 0))
+#define RDEBUG_ENABLED2()      (do_output && (rc_debug_flag > 1))
 
 #define REDEBUG(fmt, ...)      if (do_output) fr_perror("(%" PRIu64 ") " fmt , request->num, ## __VA_ARGS__)
-#define RDEBUG(fmt, ...)       if (do_output && (fr_debug_flag > 0)) fprintf(fr_log_fp, "(%" PRIu64 ") " fmt "\n", request->num, ## __VA_ARGS__)
-#define RDEBUG2(fmt, ...)      if (do_output && (fr_debug_flag > 1)) fprintf(fr_log_fp, "(%" PRIu64 ") " fmt "\n", request->num, ## __VA_ARGS__)
+#define RDEBUG(fmt, ...)       if (do_output && (rc_debug_flag > 0)) fprintf(fr_log_fp, "(%" PRIu64 ") " fmt "\n", request->num, ## __VA_ARGS__)
+#define RDEBUG2(fmt, ...)      if (do_output && (rc_debug_flag > 1)) fprintf(fr_log_fp, "(%" PRIu64 ") " fmt "\n", request->num, ## __VA_ARGS__)
 
 typedef struct rc_stats {
        uint64_t accepted;              //!< Requests to which we received a accept
index a124c85..f1ee9bd 100644 (file)
@@ -73,6 +73,8 @@ static int sleep_time = -1;
 static rc_request_t *request_head = NULL;
 static rc_request_t *rc_request_tail = NULL;
 
+static int rc_debug_flag;
+
 char const *radclient_version = "radclient version " RADIUSD_VERSION_STRING
 #ifdef RADIUSD_VERSION_COMMIT
 " (git #" STRINGIFY(RADIUSD_VERSION_COMMIT) ")"
@@ -1038,7 +1040,13 @@ int main(int argc, char **argv)
        rc_request_t    *this;
        int force_af = AF_UNSPEC;
 
-       fr_debug_flag = 2;
+       /*
+        *      It's easier having two sets of flags to set the
+        *      verbosity of library calls and the verbosity of
+        *      radclient.
+        */
+       rc_debug_flag = 1;
+       fr_debug_flag = 0;
        fr_log_fp = stdout;
 
 #ifndef NDEBUG
@@ -1148,6 +1156,7 @@ int main(int argc, char **argv)
                        do_output = false;
                        fr_log_fp = NULL; /* no output from you, either! */
                        break;
+
                case 'r':
                        if (!isdigit((int) *optarg))
                                usage();
@@ -1197,6 +1206,7 @@ int main(int argc, char **argv)
                        break;
                case 'x':
                        fr_debug_flag++;
+                       rc_debug_flag++;
                        break;
                case 'h':
                default: