]> rtime.felk.cvut.cz Git - frescor/fwp.git/commitdiff
wme_test: Added -l switch to select logging levels
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 13 Aug 2009 11:31:49 +0000 (13:31 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 13 Aug 2009 11:37:51 +0000 (13:37 +0200)
Works only when compiled with uLUt

wme_test/wclient.c

index 8c1585bfc1d55226934b3e7b902bfe53f8ccdaca..646674a041e7f891e7769b3df2339fdcd64de648 100644 (file)
 #include <inttypes.h>
 #include <ncurses.h>
 
+#ifdef WITH_FWP
+#include <ul_logreg.h>
+#endif
+
 #ifdef WITH_FWP
 #include <frsh.h>
 #include <fwp_res.h>
@@ -999,6 +1003,13 @@ void print_status_nogui(int seconds)
        fflush(stderr);
 }
 
+#ifdef WITH_FWP
+int print_log_domain(ul_log_domain_t *domain, void *context)
+{
+       printf("%s = %d\n", domain->name, domain->level);
+       return 0;
+}
+#endif
 int main(int argc, char *argv[])
 {
        int i, rc, frames, seconds;
@@ -1007,7 +1018,7 @@ int main(int argc, char *argv[])
        char opt;
 
 
-       while ((opt = getopt(argc, argv, "B:b:C:c:Gg:I:j:o:qQ:s:T:")) != -1) {
+       while ((opt = getopt(argc, argv, "B:b:C:c:Gg:I:j:l:o:qQ:s:T:")) != -1) {
                switch (opt) {
                        case 'B':
                                opt_def_bandwidth = atoi(optarg);
@@ -1048,6 +1059,20 @@ int main(int argc, char *argv[])
                                opt_jitter = atoi(optarg);
                                #endif
                                break;
+#ifdef WITH_FWP
+                       case 'l':
+                               if (*optarg == '?') {
+                                       ul_logreg_for_each_domain(print_log_domain, NULL);
+                                       exit(0);
+                               }
+                               {
+                                       int ret;
+                                       ret = ul_log_domain_arg2levels(optarg);
+                                       if (ret) 
+                                               error(1, EINVAL, "Error parsing -l argument at char %d\n", ret);
+                               }
+                               break;
+#endif
                        case 'o':
                                opt_output = optarg;
                                break;
@@ -1072,6 +1097,9 @@ int main(int argc, char *argv[])
                                fprintf(stderr, "    -c  count (number of seconds to run)\n");
                                fprintf(stderr, "    -g  histogram granularity [usec]\n");
                                fprintf(stderr, "    -I  <interface> send packets from this interface\n");
+#ifdef WITH_FWP
+                               fprintf(stderr, "    -l  <loglevel> uLUt logging levels\n");
+#endif
                                fprintf(stderr, "    -j  send jitter (0-100) [%%]\n");
                                fprintf(stderr, "    -o  output filename (.dat will be appended)\n");
                                fprintf(stderr, "    -q  gather statistics only after some queue becomes full\n");