1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

allow enabling debug contexts from test apps

Adds a -d switch to everything so you can set the log level bitfeld.

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2013-01-10 22:28:59 +08:00
parent 43db045ff8
commit 46ef0cf3c5
5 changed files with 40 additions and 15 deletions

View 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;
}

View 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);
}
}

View 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;
}

View 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);
}
}

View 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);
}
}