Change in osmo-bsc[master]: Meas Tools: Avoid OSMO_ASSERT to due uninitialised logging.

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

keith gerrit-no-reply at lists.osmocom.org
Sat Mar 28 00:57:45 UTC 2020


keith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/17647 )


Change subject: Meas Tools: Avoid OSMO_ASSERT to due uninitialised logging.
......................................................................

Meas Tools: Avoid OSMO_ASSERT to due uninitialised logging.

The measurement tools use libosmocore socket functions that will
use logging if the socket cannot be opened, but the tools did
not initialise logging, resulting in

 Assert failed osmo_log_info logging.c:235
 backtrace() returned 9 addresses
 [.....]

Initialise logging so that we get a nicer and more informative
message, such as:

 unable to bind socket:(null):8888: Address already in use
 no suitable addr found for: (null):8888

Change-Id: Ib3b3558723682defcee22e7ea2d8bf5c2cff1278
---
M src/utils/meas_json.c
M src/utils/meas_vis.c
2 files changed, 43 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/47/17647/1

diff --git a/src/utils/meas_json.c b/src/utils/meas_json.c
index a3526de..171409a 100644
--- a/src/utils/meas_json.c
+++ b/src/utils/meas_json.c
@@ -171,8 +171,29 @@
 	return 0;
 }
 
+static const struct log_info_cat categories[] = {
+	[0] = {
+		.name = "MEAS_JSON",
+		.description = "Measurement Utility",
+		.loglevel = LOGL_DEBUG,
+		.enabled = 1,
+	},
+};
+
+static const struct log_info log_info = {
+	.cat = categories,
+	.num_cat = ARRAY_SIZE(categories),
+};
+
 int main(int argc, char **argv)
 {
+	struct log_target *stderr_target;
+	log_init(&log_info, NULL);
+	stderr_target = log_target_create_stderr();
+	log_add_target(stderr_target);
+	log_set_use_color(stderr_target, 0);
+	log_set_print_filename(stderr_target, 0);
+
 	int rc;
 	struct osmo_fd udp_ofd;
 
diff --git a/src/utils/meas_vis.c b/src/utils/meas_vis.c
index cba08f5..686cfb9 100644
--- a/src/utils/meas_vis.c
+++ b/src/utils/meas_vis.c
@@ -13,6 +13,7 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/select.h>
 #include <osmocom/core/talloc.h>
+#include <osmocom/core/logging.h>
 
 #include <osmocom/gsm/gsm_utils.h>
 
@@ -258,11 +259,32 @@
 	{ 0, NULL }
 };
 
+static const struct log_info_cat categories[] = {
+	[0] = {
+		.name = "MEAS_VIS",
+		.description = "Measurement Utility",
+		.loglevel = LOGL_DEBUG,
+		.enabled = 1,
+	},
+};
+
+static const struct log_info log_info = {
+	.cat = categories,
+	.num_cat = ARRAY_SIZE(categories),
+};
+
 int main(int argc, char **argv)
 {
 	int rc;
 	char *header[1];
 	char *title[1];
+	struct log_target *stderr_target;
+
+	log_init(&log_info, NULL);
+	stderr_target = log_target_create_stderr();
+	log_add_target(stderr_target);
+	log_set_use_color(stderr_target, 0);
+	log_set_print_filename(stderr_target, 0);
 
 	msgb_talloc_ctx_init(NULL, 0);
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/17647
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ib3b3558723682defcee22e7ea2d8bf5c2cff1278
Gerrit-Change-Number: 17647
Gerrit-PatchSet: 1
Gerrit-Owner: keith <keith at rhizomatica.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200328/424491e0/attachment.htm>


More information about the gerrit-log mailing list