bts-omldummy: Support configuring logging through cmdline

Add cmdline args to control logging, as already present in other more
usual bts models.
This is extremely important here since there's no VTY at all to
configure them.

Change-Id: I0b33919d71bacefe60be192810518fd927625127
This commit is contained in:
Pau Espin Pedrol
2024-11-21 19:01:31 +01:00
parent 8797837deb
commit c8946a077e

View File

@@ -7,6 +7,7 @@
#include <osmocom/core/talloc.h>
#include <osmocom/core/application.h>
#include <osmocom/core/logging.h>
#include <osmo-bts/logging.h>
#include <osmo-bts/abis.h>
#include <osmo-bts/bts.h>
@@ -44,10 +45,14 @@ void parse_cmdline(int argc, char **argv)
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"features", 1, 0, 'f'},
{ "debug", 1, 0, 'd' },
{ "disable-color", 0, 0, 's' },
{ "timestamp", 0, 0, 'T' },
{ "log-level", 1, 0, 'e' },
{0}
};
c = getopt_long(argc, argv, "hf:", long_options, &option_index);
c = getopt_long(argc, argv, "hf:d:sTe:", long_options, &option_index);
if (c == -1)
break;
@@ -58,6 +63,18 @@ void parse_cmdline(int argc, char **argv)
case 'f':
cmdline.features = optarg;
break;
case 's':
log_set_use_color(osmo_stderr_target, 0);
break;
case 'd':
log_parse_category_mask(osmo_stderr_target, optarg);
break;
case 'T':
log_set_print_timestamp(osmo_stderr_target, 1);
break;
case 'e':
log_set_log_level(osmo_stderr_target, atoi(optarg));
break;
default:
/* catch unknown options *as well as* missing arguments. */
fprintf(stderr, "Error in command line options. Exiting.\n");
@@ -111,13 +128,13 @@ int main(int argc, char **argv)
struct bsc_oml_host *bsc_oml_host;
int i;
parse_cmdline(argc, argv);
tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context");
msgb_talloc_ctx_init(tall_bts_ctx, 10*1024);
osmo_init_logging2(tall_bts_ctx, &bts_log_info);
parse_cmdline(argc, argv);
g_bts_sm = gsm_bts_sm_alloc(tall_bts_ctx);
if (!g_bts_sm)
exit(1);