aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2011-06-12 15:15:30 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2011-06-12 15:15:30 +0200
commite19c70a9ed605d13abb25bc4c875d4741e19530e (patch)
treea810c9292c58ca1381260391739f71ec72ecc79b
parent0b099b27df4325f48749e2cec10dc6f52a21c513 (diff)
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.
-rw-r--r--src/e1_input.c2
-rw-r--r--src/init.c44
-rw-r--r--tests/e1inp_ipa_bsc_test.c27
3 files changed, 70 insertions, 3 deletions
diff --git a/src/e1_input.c b/src/e1_input.c
index 1d02e473..3453ad09 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -583,7 +583,7 @@ int e1inp_line_update(struct e1inp_line *line, enum e1inp_line_role role)
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 f4618568..f0154435 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 b9b3711c..6c1caccf 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 @@ static int error(struct msgb *msg, int error)
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 @@ int main(void)
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 @@ int main(void)
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 @@ int main(void)
*/
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);
}