add '-d' command line argument to configure stderr logging verbosity

The '-d' option is pretty much tradition in most osmocom programs,
particularly for those without a VTY / config file it is the only
option to configure per-subsystem logging verbosity.

Change-Id: I0abecc26a5d8b6a5607e1eb8982af4c05909afed
This commit is contained in:
Harald Welte 2020-05-25 14:55:12 +02:00
parent e580c93169
commit 80a0110f77
3 changed files with 18 additions and 3 deletions

View File

@ -271,6 +271,7 @@ static void printf_help()
printf(
" -h --help Print this help message\n"
" -V --version Print the version of the program\n"
" -d --debug option Enable debug logging (e.g. DMAIN:DST2)\n"
" -i --server-host A.B.C.D remsim-server IP address (default: 127.0.0.1)\n"
" -p --server-port <1-65535> remsim-server TCP port (default: 9998)\n"
" -b --bank-id <1-65535> Bank Identifier of this SIM bank (default: 1)\n"
@ -292,6 +293,7 @@ void handle_options(int argc, char **argv)
static const struct option long_options[] = {
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ "debug", 1, 0, 'd' },
{ "server-host", 1, 0, 'i' },
{ "server-port", 1, 0, 'p' },
{ "bank-id", 1, 0, 'b' },
@ -302,7 +304,7 @@ void handle_options(int argc, char **argv)
{ 0, 0, 0, 0 }
};
c = getopt_long(argc, argv, "hVi:o:b:n:N:I:P:", long_options, &option_index);
c = getopt_long(argc, argv, "hVd:i:o:b:n:N:I:P:", long_options, &option_index);
if (c == -1)
break;
@ -315,6 +317,9 @@ void handle_options(int argc, char **argv)
printf("osmo-remsim-bankd version %s\n", VERSION);
exit(0);
break;
case 'd':
log_parse_category_mask(osmo_stderr_target, optarg);
break;
case 'i':
g_bankd->srvc.server_host = optarg;
break;

View File

@ -24,6 +24,7 @@ static void printf_help()
printf(
" -h --help Print this help message\n"
" -v --version Print program version\n"
" -d --debug option Enable debug logging (e.g. DMAIN:DST2)\n"
" -i --server-ip A.B.C.D remsim-server IP address\n"
" -p --server-port 13245 remsim-server TCP port\n"
" -c --client-id <0-65535> RSPRO ClientId of this client\n"
@ -50,6 +51,7 @@ static void handle_options(struct client_config *cfg, int argc, char **argv)
static const struct option long_options[] = {
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ "debug", 1, 0, 'd' },
{ "server-ip", 1, 0, 'i' },
{ "server-port", 1, 0, 'p' },
{ "client-id", 1, 0, 'c' },
@ -68,7 +70,7 @@ static void handle_options(struct client_config *cfg, int argc, char **argv)
{ 0, 0, 0, 0 }
};
c = getopt_long(argc, argv, "hvi:p:c:n:e:"
c = getopt_long(argc, argv, "hvd:i:p:c:n:e:"
#ifdef USB_SUPPORT
"V:P:C:I:S:A:H:"
#endif
@ -86,6 +88,9 @@ static void handle_options(struct client_config *cfg, int argc, char **argv)
printf("osmo-remsim-client version %s\n", VERSION);
exit(0);
break;
case 'd':
log_parse_category_mask(osmo_stderr_target, optarg);
break;
case 'i':
osmo_talloc_replace_string(cfg, &cfg->server_host, optarg);
break;

View File

@ -33,6 +33,7 @@ static void print_help()
printf( " Some useful help...\n"
" -h --help This text\n"
" -V --version Print version of the program\n"
" -d --debug option Enable debug logging (e.g. DMAIN:DST2)\n"
);
}
@ -43,10 +44,11 @@ static void handle_options(int argc, char **argv)
static struct option long_options[] = {
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ "debug", 1, 0, 'd' },
{0, 0, 0, 0}
};
c = getopt_long(argc, argv, "hV", long_options, &option_index);
c = getopt_long(argc, argv, "hVd:", long_options, &option_index);
if (c == -1)
break;
@ -55,6 +57,9 @@ static void handle_options(int argc, char **argv)
print_help();
exit(0);
break;
case 'd':
log_parse_category_mask(osmo_stderr_target, optarg);
break;
case 'V':
printf("osmo-resmim-server version %s\n", VERSION);
exit(0);