Hoernchen submitted this change.
layer23: fix handling of logging category mask (-d option)
In change 67943df4 I broke handling of the logging category mask in
the mobile app. Adding this option results in a segfault:
ERROR: osmo_log_info == NULL! You must call log_init() before
using logging in log_parse_category_mask()!
Assert failed osmo_log_info src/libosmocore/src/core/logging.c:329
As can be seen, the problem is that we are calling
log_parse_category_mask() before initializing the logging.
As possible solution, I could rearrange the code to parse command
line options after calling osmo_init_logging2(). This would fix
the segfault, but would not fully solve the problem.
If we call log_parse_category_mask() before parsing the config file,
then logging configuration in the config file overwrites the logging
configuration specified via the command line. But we want the
opposite: the command line setting should overwrite the config file
parameters. This is handy because there is no need to edit the
config file if you quickly need to test something.
So let's call log_parse_category_mask() after parsing the config file.
Change-Id: I1b2b7804bf99b71f96e9197f7824cfd20431e8a1
Fixes: 67943df4 "layer23: fix parsing of command line options"
---
M src/host/layer23/src/common/main.c
M src/host/layer23/src/mobile/main.c
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/src/host/layer23/src/common/main.c b/src/host/layer23/src/common/main.c
index a4b9441..919a231 100644
--- a/src/host/layer23/src/common/main.c
+++ b/src/host/layer23/src/common/main.c
@@ -58,6 +58,7 @@
struct llist_head ms_list;
static char *gsmtap_ip = NULL;
static char *config_file = NULL;
+static char *log_cat_mask = NULL;
int (*l23_app_start)(void) = NULL;
int (*l23_app_work)(void) = NULL;
@@ -162,7 +163,7 @@
config_file = optarg;
break;
case 'd':
- log_parse_category_mask(osmo_stderr_target, optarg);
+ log_cat_mask = optarg;
break;
default:
if (l23_app_info.cfg_handle_opt != NULL)
@@ -268,6 +269,9 @@
exit(1);
}
+ if (log_cat_mask != NULL)
+ log_parse_category_mask(osmo_stderr_target, log_cat_mask);
+
if (l23_app_info.opt_supported & L23_OPT_TAP) {
if (gsmtap_ip) {
if (l23_cfg.gsmtap.remote_host != NULL) {
diff --git a/src/host/layer23/src/mobile/main.c b/src/host/layer23/src/mobile/main.c
index 71a16c1..8720ea7 100644
--- a/src/host/layer23/src/mobile/main.c
+++ b/src/host/layer23/src/mobile/main.c
@@ -54,6 +54,7 @@
struct l23_global_config l23_cfg;
struct llist_head ms_list;
static const char *custom_cfg_file = NULL;
+static const char *log_cat_mask = NULL;
static char *config_file = NULL;
char *config_dir = NULL;
int daemonize = 0;
@@ -118,7 +119,7 @@
custom_cfg_file = optarg;
break;
case 'd':
- log_parse_category_mask(osmo_stderr_target, optarg);
+ log_cat_mask = optarg;
break;
case 'D':
daemonize = 1;
@@ -297,6 +298,9 @@
exit(1);
}
+ if (log_cat_mask != NULL)
+ log_parse_category_mask(osmo_stderr_target, log_cat_mask);
+
if (l23_cfg.gsmtap.remote_host) {
l23_cfg.gsmtap.inst = gsmtap_source_init2(l23_cfg.gsmtap.local_host, 0,
l23_cfg.gsmtap.remote_host, GSMTAP_UDP_PORT, 1);
To view, visit change 33329. To unsubscribe, or for help writing mail filters, visit settings.