[PATCH] libosmocore[master]: log: print loginfo assertions source

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/.

Max gerrit-no-reply at lists.osmocom.org
Thu Jan 11 10:23:50 UTC 2018


Review at  https://gerrit.osmocom.org/5748

log: print loginfo assertions source

Print which function has triggered assert_loginfo(). It's handy in
debugging logging-related issues in libosmocore.

Change-Id: I8418d0c431106f50aa8779cd89396f02373304ad
---
M src/logging.c
1 file changed, 8 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/48/5748/1

diff --git a/src/logging.c b/src/logging.c
index 20ec443..1e0b21b 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -182,11 +182,11 @@
 	NULL,
 };
 
-static void assert_loginfo(void)
+static void assert_loginfo(const char *src)
 {
 	if (!osmo_log_info) {
 		fprintf(stderr, "ERROR: osmo_log_info == NULL! "
-			"You must call log_init() before using logging!\n");
+			"You must call log_init() before using logging in %s()!\n", src);
 		OSMO_ASSERT(osmo_log_info);
 	}
 }
@@ -223,7 +223,7 @@
 {
 	int i;
 
-	assert_loginfo();
+	assert_loginfo(__func__);
 
 	for (i = 0; i < osmo_log_info->num_cat; ++i) {
 		if (osmo_log_info->cat[i].name == NULL)
@@ -248,7 +248,7 @@
 	char *mask = strdup(_mask);
 	char *category_token = NULL;
 
-	assert_loginfo();
+	assert_loginfo(__func__);
 
 	/* Disable everything to enable it afterwards */
 	for (i = 0; i < osmo_log_info->num_cat; ++i)
@@ -653,7 +653,7 @@
 	struct log_target *target;
 	unsigned int i;
 
-	assert_loginfo();
+	assert_loginfo(__func__);
 
 	target = talloc_zero(tall_log_ctx, struct log_target);
 	if (!target)
@@ -827,7 +827,7 @@
 	int size = strlen("logging level () ()") + 1;
 	char *str;
 
-	assert_loginfo();
+	assert_loginfo(__func__);
 
 	for (i = 0; i < info->num_cat; i++) {
 		if (info->cat[i].name == NULL)
@@ -909,7 +909,7 @@
 		strlen(LOGGING_STR
 		       "Set the log level for a specified category\n") + 1;
 
-	assert_loginfo();
+	assert_loginfo(__func__);
 
 	for (i = 0; i < info->num_cat; i++) {
 		if (info->cat[i].name == NULL)
@@ -1028,7 +1028,7 @@
 {
 	struct log_target *tar;
 
-	assert_loginfo();
+	assert_loginfo(__func__);
 
 	subsys = map_subsys(subsys);
 

-- 
To view, visit https://gerrit.osmocom.org/5748
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8418d0c431106f50aa8779cd89396f02373304ad
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list