[MERGED] osmo-msc[master]: dissolve libcommon: drop debug.c

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Mar 22 17:27:44 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: dissolve libcommon: drop debug.c
......................................................................


dissolve libcommon: drop debug.c

Apply more concise logging categories in each main scope. The bulk goes to
msc_main.c, obviously, while tests and utils get a slimmed down bunch of
logging categories.

Change-Id: I969a0662ba273f3721b6820d02151b7a5b8014b8
---
M include/osmocom/msc/debug.h
M src/libcommon/Makefile.am
D src/libcommon/debug.c
M src/libcommon/gsup_test_client.c
M src/libcommon/oap_client.c
M src/libmsc/smpp_utils.c
M src/osmo-msc/msc_main.c
M src/utils/smpp_mirror.c
M tests/smpp/smpp_test.c
9 files changed, 140 insertions(+), 158 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/msc/debug.h b/include/osmocom/msc/debug.h
index 384453e..717cf74 100644
--- a/include/osmocom/msc/debug.h
+++ b/include/osmocom/msc/debug.h
@@ -1,9 +1,5 @@
 #pragma once
 
-#include <stdio.h>
-#include <osmocom/core/linuxlist.h>
-
-#define DEBUG
 #include <osmocom/core/logging.h>
 
 /* Debug Areas of the code */
@@ -27,5 +23,3 @@
 	DBSSAP,
 	Debug_LastEntry,
 };
-
-extern const struct log_info log_info;
diff --git a/src/libcommon/Makefile.am b/src/libcommon/Makefile.am
index e96faef..5bd1c2f 100644
--- a/src/libcommon/Makefile.am
+++ b/src/libcommon/Makefile.am
@@ -20,7 +20,6 @@
 	$(NULL)
 
 libcommon_a_SOURCES = \
-	debug.c \
 	gsm_data.c \
 	gsup_client.c \
 	oap_client.c \
diff --git a/src/libcommon/debug.c b/src/libcommon/debug.c
deleted file mode 100644
index fbdab80..0000000
--- a/src/libcommon/debug.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* OpenBSC Debugging/Logging support code */
-
-/* (C) 2008-2010 by Harald Welte <laforge at gnumonks.org>
- * (C) 2008 by Holger Hans Peter Freyther <zecke at selfish.org>
- * All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <time.h>
-#include <errno.h>
-
-#include <osmocom/core/talloc.h>
-#include <osmocom/core/utils.h>
-#include <osmocom/core/logging.h>
-#include <osmocom/gprs/gprs_msgb.h>
-#include <osmocom/msc/gsm_data.h>
-#include <osmocom/msc/debug.h>
-
-/* default categories */
-static const struct log_info_cat default_categories[] = {
-	[DRLL] = {
-		.name = "DRLL",
-		.description = "A-bis Radio Link Layer (RLL)",
-		.color = "\033[1;31m",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DCC] = {
-		.name = "DCC",
-		.description = "Layer3 Call Control (CC)",
-		.color = "\033[1;32m",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DMM] = {
-		.name = "DMM",
-		.description = "Layer3 Mobility Management (MM)",
-		.color = "\033[1;33m",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DRR] = {
-		.name = "DRR",
-		.description = "Layer3 Radio Resource (RR)",
-		.color = "\033[1;34m",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DMNCC] = {
-		.name = "DMNCC",
-		.description = "MNCC API for Call Control application",
-		.color = "\033[1;39m",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DPAG]	= {
-		.name = "DPAG",
-		.description = "Paging Subsystem",
-		.color = "\033[1;38m",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DMSC] = {
-		.name = "DMSC",
-		.description = "Mobile Switching Center",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DMGCP] = {
-		.name = "DMGCP",
-		.description = "Media Gateway Control Protocol",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DHO] = {
-		.name = "DHO",
-		.description = "Hand-Over",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DDB] = {
-		.name = "DDB",
-		.description = "Database Layer",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DREF] = {
-		.name = "DREF",
-		.description = "Reference Counting",
-		.enabled = 0, .loglevel = LOGL_NOTICE,
-	},
-	[DCTRL] = {
-		.name = "DCTRL",
-		.description = "Control interface",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-	[DSMPP] = {
-		.name = "DSMPP",
-		.description = "SMPP interface for external SMS apps",
-		.enabled = 1, .loglevel = LOGL_DEBUG,
-	},
-	[DRANAP] = {
-		.name = "DRANAP",
-		.description = "Radio Access Network Application Part Protocol",
-		.enabled = 1, .loglevel = LOGL_DEBUG,
-	},
-	[DVLR] = {
-		.name = "DVLR",
-		.description = "Visitor Location Register",
-		.enabled = 1, .loglevel = LOGL_DEBUG,
-	},
-	[DIUCS] = {
-		.name = "DIUCS",
-		.description = "Iu-CS Protocol",
-		.enabled = 1, .loglevel = LOGL_DEBUG,
-	},
-	[DBSSAP] = {
-		.name = "DBSSAP",
-		.description = "BSSAP Protocol (A Interface)",
-		.enabled = 1, .loglevel = LOGL_NOTICE,
-	},
-
-};
-
-static int filter_fn(const struct log_context *ctx, struct log_target *tar)
-{
-	const struct vlr_subscr *vsub = ctx->ctx[LOG_CTX_VLR_SUBSCR];
-
-	if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0
-	    && vsub && vsub == tar->filter_data[LOG_FLT_VLR_SUBSCR])
-		return 1;
-
-	return 0;
-}
-
-const struct log_info log_info = {
-	.filter_fn = filter_fn,
-	.cat = default_categories,
-	.num_cat = ARRAY_SIZE(default_categories),
-};
diff --git a/src/libcommon/gsup_test_client.c b/src/libcommon/gsup_test_client.c
index 8b6199e..3e88689 100644
--- a/src/libcommon/gsup_test_client.c
+++ b/src/libcommon/gsup_test_client.c
@@ -8,10 +8,10 @@
 #include <osmocom/core/select.h>
 #include <osmocom/core/application.h>
 #include <osmocom/core/utils.h>
+#include <osmocom/core/logging.h>
 #include <osmocom/gsm/gsup.h>
 
 #include <osmocom/msc/gsup_client.h>
-#include <osmocom/msc/debug.h>
 
 static struct gsup_client *g_gc;
 
diff --git a/src/libcommon/oap_client.c b/src/libcommon/oap_client.c
index 7154baa..137515a 100644
--- a/src/libcommon/oap_client.c
+++ b/src/libcommon/oap_client.c
@@ -24,6 +24,7 @@
 #include <errno.h>
 
 #include <osmocom/core/utils.h>
+#include <osmocom/core/logging.h>
 #include <osmocom/crypt/auth.h>
 #include <osmocom/gsm/oap.h>
 
diff --git a/src/libmsc/smpp_utils.c b/src/libmsc/smpp_utils.c
index 7208e25..7fffdd2 100644
--- a/src/libmsc/smpp_utils.c
+++ b/src/libmsc/smpp_utils.c
@@ -19,8 +19,7 @@
 
 
 #include "smpp_smsc.h"
-#include <osmocom/msc/debug.h>
-
+#include <osmocom/core/logging.h>
 
 int smpp_determine_scheme(uint8_t dcs, uint8_t *data_coding, int *mode)
 {
diff --git a/src/osmo-msc/msc_main.c b/src/osmo-msc/msc_main.c
index 6de81da..1cf2642 100644
--- a/src/osmo-msc/msc_main.c
+++ b/src/osmo-msc/msc_main.c
@@ -401,6 +401,118 @@
 	return 0;
 }
 
+static const struct log_info_cat msc_default_categories[] = {
+	[DRLL] = {
+		.name = "DRLL",
+		.description = "A-bis Radio Link Layer (RLL)",
+		.color = "\033[1;31m",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DCC] = {
+		.name = "DCC",
+		.description = "Layer3 Call Control (CC)",
+		.color = "\033[1;32m",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DMM] = {
+		.name = "DMM",
+		.description = "Layer3 Mobility Management (MM)",
+		.color = "\033[1;33m",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DRR] = {
+		.name = "DRR",
+		.description = "Layer3 Radio Resource (RR)",
+		.color = "\033[1;34m",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DMNCC] = {
+		.name = "DMNCC",
+		.description = "MNCC API for Call Control application",
+		.color = "\033[1;39m",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DPAG]	= {
+		.name = "DPAG",
+		.description = "Paging Subsystem",
+		.color = "\033[1;38m",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DMSC] = {
+		.name = "DMSC",
+		.description = "Mobile Switching Center",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DMGCP] = {
+		.name = "DMGCP",
+		.description = "Media Gateway Control Protocol",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DHO] = {
+		.name = "DHO",
+		.description = "Hand-Over",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DDB] = {
+		.name = "DDB",
+		.description = "Database Layer",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DREF] = {
+		.name = "DREF",
+		.description = "Reference Counting",
+		.enabled = 0, .loglevel = LOGL_NOTICE,
+	},
+	[DCTRL] = {
+		.name = "DCTRL",
+		.description = "Control interface",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DSMPP] = {
+		.name = "DSMPP",
+		.description = "SMPP interface for external SMS apps",
+		.enabled = 1, .loglevel = LOGL_DEBUG,
+	},
+	[DRANAP] = {
+		.name = "DRANAP",
+		.description = "Radio Access Network Application Part Protocol",
+		.enabled = 1, .loglevel = LOGL_DEBUG,
+	},
+	[DVLR] = {
+		.name = "DVLR",
+		.description = "Visitor Location Register",
+		.enabled = 1, .loglevel = LOGL_DEBUG,
+	},
+	[DIUCS] = {
+		.name = "DIUCS",
+		.description = "Iu-CS Protocol",
+		.enabled = 1, .loglevel = LOGL_DEBUG,
+	},
+	[DBSSAP] = {
+		.name = "DBSSAP",
+		.description = "BSSAP Protocol (A Interface)",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+
+};
+
+static int filter_fn(const struct log_context *ctx, struct log_target *tar)
+{
+	const struct vlr_subscr *vsub = ctx->ctx[LOG_CTX_VLR_SUBSCR];
+
+	if ((tar->filter_map & (1 << LOG_FLT_VLR_SUBSCR)) != 0
+	    && vsub && vsub == tar->filter_data[LOG_FLT_VLR_SUBSCR])
+		return 1;
+
+	return 0;
+}
+
+const struct log_info log_info = {
+	.filter_fn = filter_fn,
+	.cat = msc_default_categories,
+	.num_cat = ARRAY_SIZE(msc_default_categories),
+};
+
 int main(int argc, char **argv)
 {
 	int rc;
diff --git a/src/utils/smpp_mirror.c b/src/utils/smpp_mirror.c
index 248396a..fa509df 100644
--- a/src/utils/smpp_mirror.c
+++ b/src/utils/smpp_mirror.c
@@ -324,6 +324,18 @@
 	return bind_transceiver(esme);
 }
 
+static const struct log_info_cat smpp_mirror_default_categories[] = {
+	[DSMPP] = {
+		.name = "DSMPP",
+		.description = "SMPP interface for external SMS apps",
+		.enabled = 1, .loglevel = LOGL_DEBUG,
+	},
+};
+
+const struct log_info log_info = {
+	.cat = smpp_mirror_default_categories,
+	.num_cat = ARRAY_SIZE(smpp_mirror_default_categories),
+};
 
 int main(int argc, char **argv)
 {
diff --git a/tests/smpp/smpp_test.c b/tests/smpp/smpp_test.c
index 5f5f2d6..4a3af49 100644
--- a/tests/smpp/smpp_test.c
+++ b/tests/smpp/smpp_test.c
@@ -62,6 +62,19 @@
 	}
 }
 
+static const struct log_info_cat smpp_mirror_default_categories[] = {
+	[DSMPP] = {
+		.name = "DSMPP",
+		.description = "SMPP interface for external SMS apps",
+		.enabled = 1, .loglevel = LOGL_DEBUG,
+	},
+};
+
+const struct log_info log_info = {
+	.cat = smpp_mirror_default_categories,
+	.num_cat = ARRAY_SIZE(smpp_mirror_default_categories),
+};
+
 int main(int argc, char **argv)
 {
 	osmo_init_logging(&log_info);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I969a0662ba273f3721b6820d02151b7a5b8014b8
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list