Cleaned up a lot of printing.
[distributedratelimiting.git] / drl / estimate.c
index ed08447..e55639b 100644 (file)
@@ -20,6 +20,7 @@
 
 static int underlimit_flowcount_count = 0;
 static int underlimit_normal_count = 0;
+extern uint8_t system_loglevel;
 
 /**
  * Called for each identity each estimate interval.  Uses flow table information
@@ -228,8 +229,10 @@ static uint32_t allocate_fps(identity_t *ident, double total_weight) {
 
     printlog(LOG_DEBUG, "%.3f %.3f IdealUnd IdealOve\n",ideal_under,ideal_over);
 
-    printf("local_rate: %d, idealweight: %.3f, localweight: %.3f, total_weight: %.3f\n",
+    if (system_loglevel == LOG_DEBUG) {
+        printf("local_rate: %d, idealweight: %.3f, localweight: %.3f, total_weight: %.3f\n",
             local_rate, idealweight, ident->localweight, total_weight);
+    }
 
     //printf("Dampen: %d, dampen_increase: %d, peer_weights: %.3f, regime: %d\n",
     //       dampen, dampen_increase, peer_weights, regime);
@@ -260,8 +263,10 @@ static double allocate_grd(identity_t *ident, double aggdemand) {
         dropprob = 0.0;
     }
     
-    printf("local rate: %d, aggregate demand: %.3f, drop prob: %.3f\n",
+    if (system_loglevel == LOG_DEBUG) {
+        printf("local rate: %d, aggregate demand: %.3f, drop prob: %.3f\n",
            ident->common.rate, aggdemand, dropprob);
+    }
 
     return dropprob;
 }
@@ -358,7 +363,9 @@ static void enforce(limiter_t *limiter, identity_t *ident) {
                 ident->locallimit = limiter->nodelimit;
             }
 
-            printf("FPS: Setting local limit to %d\n", ident->locallimit);
+            if (system_loglevel == LOG_DEBUG) {
+                printf("FPS: Setting local limit to %d\n", ident->locallimit);
+            }
             printlog(LOG_DEBUG, "%d Limit ID:%d\n", ident->locallimit, ident->id);
 
             snprintf(cmd, CMD_BUFFER_SIZE,