allow enabling debug contexts from test apps
authorAndy Green <andy.green@linaro.org>
Thu, 10 Jan 2013 14:28:59 +0000 (22:28 +0800)
committerAndy Green <andy.green@linaro.org>
Thu, 10 Jan 2013 15:34:33 +0000 (23:34 +0800)
Adds a -d switch to everything so you can set the log level bitfeld.

Signed-off-by: Andy Green <andy.green@linaro.org>
test-server/test-client.c
test-server/test-fraggle.c
test-server/test-ping.c
test-server/test-server-extpoll.c
test-server/test-server.c

index babdea8..4d8d474 100644 (file)
@@ -187,6 +187,7 @@ static struct libwebsocket_protocols protocols[] = {
 
 static struct option options[] = {
        { "help",       no_argument,            NULL, 'h' },
+       { "debug",      required_argument,      NULL, 'd' },
        { "port",       required_argument,      NULL, 'p' },
        { "ssl",        no_argument,            NULL, 's' },
        { "killmask",   no_argument,            NULL, 'k' },
@@ -209,17 +210,20 @@ int main(int argc, char **argv)
        int mirror_lifetime = 0;
 
        fprintf(stderr, "libwebsockets test client\n"
-                       "(C) Copyright 2010 Andy Green <andy@warmcat.com> "
+                       "(C) Copyright 2010-2013 Andy Green <andy@warmcat.com> "
                                                    "licensed under LGPL2.1\n");
 
        if (argc < 2)
                goto usage;
 
        while (n >= 0) {
-               n = getopt_long(argc, argv, "nuv:khsp:", options, NULL);
+               n = getopt_long(argc, argv, "nuv:khsp:d:", options, NULL);
                if (n < 0)
                        continue;
                switch (n) {
+               case 'd':
+                       lws_set_log_level(atoi(optarg));
+                       break;
                case 's':
                        use_ssl = 2; /* 2 = allow selfsigned */
                        break;
@@ -264,7 +268,6 @@ int main(int argc, char **argv)
                return 1;
        }
 
-
        /* create a client websocket using dumb increment protocol */
 
        wsi_dumb = libwebsocket_client_connect(context, address, port, use_ssl,
@@ -335,7 +338,8 @@ int main(int argc, char **argv)
 
 usage:
        fprintf(stderr, "Usage: libwebsockets-test-client "
-                                            "<server address> [--port=<p>] "
-                                            "[--ssl] [-k] [-v <ver>]\n");
+                               "<server address> [--port=<p>] "
+                               "[--ssl] [-k] [-v <ver>] "
+                               "[-d <log bitfield>]\n");
        return 1;
 }
index 9c2a166..14cc3cd 100644 (file)
@@ -228,6 +228,7 @@ static struct libwebsocket_protocols protocols[] = {
 
 static struct option options[] = {
        { "help",       no_argument,            NULL, 'h' },
+       { "debug",      required_argument,      NULL, 'd' },
        { "port",       required_argument,      NULL, 'p' },
        { "ssl",        no_argument,            NULL, 's' },
        { "killmask",   no_argument,            NULL, 'k' },
@@ -258,10 +259,13 @@ int main(int argc, char **argv)
                                                    "licensed under LGPL2.1\n");
 
        while (n >= 0) {
-               n = getopt_long(argc, argv, "ci:khsp:", options, NULL);
+               n = getopt_long(argc, argv, "ci:khsp:d:", options, NULL);
                if (n < 0)
                        continue;
                switch (n) {
+               case 'd':
+                       lws_set_log_level(atoi(optarg));
+                       break;
                case 's':
                        use_ssl = 1;
                        break;
@@ -283,7 +287,9 @@ int main(int argc, char **argv)
                        break;
                case 'h':
                        fprintf(stderr, "Usage: libwebsockets-test-fraggle "
-                                          "[--port=<p>] [--ssl] [--client]\n");
+                                       "[--port=<p>] [--ssl] "
+                                       "[-d <log bitfield>] "
+                                       "[--client]\n");
                        exit(1);
                }
        }
index 864a028..93df59e 100644 (file)
@@ -287,6 +287,7 @@ static struct libwebsocket_protocols protocols[] = {
 
 static struct option options[] = {
        { "help",       no_argument,            NULL, 'h' },
+       { "debug",      required_argument,      NULL, 'd' },
        { "port",       required_argument,      NULL, 'p' },
        { "ssl",        no_argument,            NULL, 't' },
        { "interval",   required_argument,      NULL, 'i' },
@@ -333,10 +334,13 @@ int main(int argc, char **argv)
        optind++;
 
        while (n >= 0) {
-               n = getopt_long(argc, argv, "v:kr:hmfts:n:i:p:", options, NULL);
+               n = getopt_long(argc, argv, "v:kr:hmfts:n:i:p:d:", options, NULL);
                if (n < 0)
                        continue;
                switch (n) {
+               case 'd':
+                       lws_set_log_level(atoi(optarg));
+                       break;
                case 'm':
                        use_mirror = 1;
                        break;
@@ -505,8 +509,9 @@ usage:
                                             "[--size=<bytes>] "
                                             "[--protocol=<protocolname>] "
                                             "[--mirror] "
-                                            "[--replicate=clients>]"
-                                            "[--version <version>]"
+                                            "[--replicate=clients>] "
+                                            "[--version <version>] "
+                                            "[-d <log bitfield> ]"
                                             "\n");
        return 1;
 }
index 1eb2d10..470997c 100644 (file)
@@ -425,6 +425,7 @@ static struct libwebsocket_protocols protocols[] = {
 
 static struct option options[] = {
        { "help",       no_argument,            NULL, 'h' },
+       { "debug",      required_argument,      NULL, 'd' },
        { "port",       required_argument,      NULL, 'p' },
        { "ssl",        no_argument,            NULL, 's' },
        { "killmask",   no_argument,            NULL, 'k' },
@@ -454,10 +455,13 @@ int main(int argc, char **argv)
                                                    "licensed under LGPL2.1\n");
 
        while (n >= 0) {
-               n = getopt_long(argc, argv, "i:khsp:", options, NULL);
+               n = getopt_long(argc, argv, "i:khsp:d:", options, NULL);
                if (n < 0)
                        continue;
                switch (n) {
+               case 'd':
+                       lws_set_log_level(atoi(optarg));
+                       break;
                case 's':
                        use_ssl = 1;
                        break;
@@ -474,7 +478,8 @@ int main(int argc, char **argv)
                        break;
                case 'h':
                        fprintf(stderr, "Usage: test-server "
-                                            "[--port=<p>] [--ssl]\n");
+                                       "[--port=<p>] [--ssl] "
+                                       "[-d <log bitfield>]\n");
                        exit(1);
                }
        }
index d202c1d..110b475 100644 (file)
@@ -379,6 +379,7 @@ static struct libwebsocket_protocols protocols[] = {
 
 static struct option options[] = {
        { "help",       no_argument,            NULL, 'h' },
+       { "debug",      required_argument,      NULL, 'd' },
        { "port",       required_argument,      NULL, 'p' },
        { "ssl",        no_argument,            NULL, 's' },
        { "killmask",   no_argument,            NULL, 'k' },
@@ -407,14 +408,17 @@ int main(int argc, char **argv)
 #endif
 
        fprintf(stderr, "libwebsockets test server\n"
-                       "(C) Copyright 2010-2011 Andy Green <andy@warmcat.com> "
+                       "(C) Copyright 2010-2013 Andy Green <andy@warmcat.com> "
                                                    "licensed under LGPL2.1\n");
 
        while (n >= 0) {
-               n = getopt_long(argc, argv, "ci:khsp:", options, NULL);
+               n = getopt_long(argc, argv, "ci:khsp:d:", options, NULL);
                if (n < 0)
                        continue;
                switch (n) {
+               case 'd':
+                       lws_set_log_level(atoi(optarg));
+                       break;
                case 's':
                        use_ssl = 1;
                        break;
@@ -437,7 +441,8 @@ int main(int argc, char **argv)
                        break;
                case 'h':
                        fprintf(stderr, "Usage: test-server "
-                                            "[--port=<p>] [--ssl]\n");
+                                       "[--port=<p>] [--ssl] "
+                                       "[-d <log bitfield>]\n");
                        exit(1);
                }
        }