src: add support for logging infrastructure in libosmo-abis

This patch uses the new libosmocore logging infrastructure
that allows to invoke log_init(&my_log_info) multiple times
so we can register categories from libraries and applications.
diff --git a/src/e1_input.c b/src/e1_input.c
index 1d02e47..3453ad0 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -583,7 +583,7 @@
 	return rc;
 }
 
-static int e1i_sig_cb(unsigned int subsys, unsigned int signal,
+static int e1i_sig_cb(uint8_t subsys, unsigned int signal,
 		      void *handler_data, void *signal_data)
 {
 	if (subsys != SS_GLOBAL ||
diff --git a/src/init.c b/src/init.c
index f461856..f015443 100644
--- a/src/init.c
+++ b/src/init.c
@@ -16,12 +16,56 @@
  *
  */
 #include "internal.h"
+#include <osmocom/core/utils.h>
+#include <osmocom/abis/logging.h>
 #include <talloc.h>
 
 void *libosmo_abis_ctx;
 
+struct log_info_cat libosmo_abis_default_categories[] = {
+	[DINP] = {
+		.name = "DINP",
+		.description = "A-bis Intput Subsystem",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DMUX] = {
+		.name = "DMUX",
+		.description = "A-bis B-Subchannel TRAU Frame Multiplex",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DMI] = {
+		.name = "DMI",
+		.description = "A-bis Input Driver for Signalling",
+		.enabled = 0, .loglevel = LOGL_NOTICE,
+	},
+	[DMIB] = {
+		.name = "DMIB",
+		.description = "A-bis Input Driver for B-Channels (voice)",
+		.enabled = 0, .loglevel = LOGL_NOTICE,
+	},
+	[DRSL] = {
+		.name = "DRSL",
+		.description = "A-bis Radio Siganlling Link (RSL)",
+		.color = "\033[1;35m",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+	[DNM] = {
+		.name = "DNM",
+		.description = "A-bis Network Management / O&M (NM/OML)",
+		.color = "\033[1;36m",
+		.enabled = 1, .loglevel = LOGL_INFO,
+	},
+};
+
+const struct log_info libosmo_abis_log_info = {
+	.filter_fn = NULL,	/* the application should set this. */
+	.cat = libosmo_abis_default_categories,
+	.num_cat = ARRAY_SIZE(libosmo_abis_default_categories),
+};
+
 void libosmo_abis_init(void *ctx)
 {
+	log_init(&libosmo_abis_log_info);
 	libosmo_abis_ctx = talloc_named_const(ctx, 0, "abis");
 	e1inp_init();
 }
diff --git a/tests/e1inp_ipa_bsc_test.c b/tests/e1inp_ipa_bsc_test.c
index b9b3711..6c1cacc 100644
--- a/tests/e1inp_ipa_bsc_test.c
+++ b/tests/e1inp_ipa_bsc_test.c
@@ -2,6 +2,8 @@
 #include <talloc.h>
 #include <osmocom/abis/abis.h>
 #include <osmocom/abis/e1_input.h>
+#include <osmocom/core/application.h>
+#include <osmocom/core/logging.h>
 
 static void *tall_test;
 
@@ -23,6 +25,23 @@
 	return 0;
 }
 
+#define DBSCTEST OSMO_LOG_SS_APPS
+
+struct log_info_cat bsc_test_cat[] = {
+	[DBSCTEST] = {
+		.name = "DBSCTEST",
+		.description = "BSC-mode test",
+		.color = "\033[1;35m",
+		.enabled = 1, .loglevel = LOGL_NOTICE,
+	},
+};
+
+const struct log_info bsc_test_log_info = {
+        .filter_fn = NULL,
+        .cat = bsc_test_cat,
+        .num_cat = ARRAY_SIZE(bsc_test_cat),
+};
+
 int main(void)
 {
 	struct e1inp_line *line;
@@ -30,6 +49,8 @@
 	tall_test = talloc_named_const(NULL, 1, "e1inp_test");
 	libosmo_abis_init(tall_test);
 
+	osmo_init_logging(&bsc_test_log_info);
+
 	struct e1inp_line_ops ops = {
 		.sign_link_up	= sign_link_up,
 		.sign_link	= sign_link,
@@ -40,7 +61,7 @@
 
 	line = e1inp_line_create(LINENR, "ipa", &ops);
 	if (line == NULL) {
-		fprintf(stderr, "problem creating E1 line\n");
+		LOGP(DBSCTEST, LOGL_ERROR, "problem creating E1 line\n");
 		exit(EXIT_FAILURE);
 	}
 
@@ -56,10 +77,12 @@
 	 */
 
 	if (e1inp_line_update(line, E1INP_LINE_R_BSC) < 0) {
-		fprintf(stderr, "problem enabling E1 line\n");
+		LOGP(DBSCTEST, LOGL_ERROR, "problem creating E1 line\n");
 		exit(EXIT_FAILURE);
 	}
 
+	LOGP(DBSCTEST, LOGL_NOTICE, "entering main loop\n");
+
 	while (1) {
 		osmo_select_main(0);
 	}