summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-01-20 13:53:56 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2020-01-21 10:52:39 +0100
commited1a2b36809473f0a1dcd1443971fb7f0fd63198 (patch)
tree9cc426fc176714282e76634ff02e0b2f424267e1
parent253e6fecb6c43a510a509bc65300a6eb2d5bf63d (diff)
example/sccp_demo_user: Use osmocom logging system instead of printf
-rw-r--r--examples/internal.h5
-rw-r--r--examples/sccp_demo_user.c6
-rw-r--r--examples/sccp_test_server.c32
3 files changed, 27 insertions, 16 deletions
diff --git a/examples/internal.h b/examples/internal.h
index 70b9058..ef560ed 100644
--- a/examples/internal.h
+++ b/examples/internal.h
@@ -5,6 +5,11 @@
#define SSN_TEST_ECHO 202
#define SSN_TEST_CALLBACK 203
+/* Debug Areas of the code */
+enum {
+ DMAIN
+};
+
struct osmo_sccp_user;
int sccp_test_user_vty_install(struct osmo_sccp_instance *inst, int ssn);
diff --git a/examples/sccp_demo_user.c b/examples/sccp_demo_user.c
index 8cf3c33..e3f5ee0 100644
--- a/examples/sccp_demo_user.c
+++ b/examples/sccp_demo_user.c
@@ -58,6 +58,12 @@ static void signal_handler(int signal)
}
static const struct log_info_cat log_info_cat[] = {
+ [DMAIN] = {
+ .name = "DMAIN",
+ .description = "sccp_demo_user specific logging",
+ .color = "\033[1;31m",
+ .enabled = 1, .loglevel = LOGL_INFO,
+ },
};
static const struct log_info log_info = {
diff --git a/examples/sccp_test_server.c b/examples/sccp_test_server.c
index a66cb21..83b42fa 100644
--- a/examples/sccp_test_server.c
+++ b/examples/sccp_test_server.c
@@ -23,15 +23,15 @@ static int refuser_prim_cb(struct osmo_prim_hdr *oph, void *_scu)
switch (OSMO_PRIM_HDR(&scu_prim->oph)) {
case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_INDICATION):
- printf("%s: refusing N-CONNECT.ind (local_ref=%u)\n",
- __func__, scu_prim->u.connect.conn_id);
+ LOGP(DMAIN, LOGL_INFO, "refusing N-CONNECT.ind (local_ref=%u)\n",
+ scu_prim->u.connect.conn_id);
osmo_sccp_tx_disconn(scu, scu_prim->u.connect.conn_id,
&scu_prim->u.connect.called_addr,
23);
break;
default:
- printf("%s: Unknown primitive %u:%u\n", __func__,
- oph->primitive, oph->operation);
+ LOGP(DMAIN, LOGL_NOTICE, "Unknown primitive %u:%u\n",
+ oph->primitive, oph->operation);
break;
}
msgb_free(oph->msg);
@@ -49,27 +49,27 @@ static int echo_prim_cb(struct osmo_prim_hdr *oph, void *_scu)
switch (OSMO_PRIM_HDR(&scu_prim->oph)) {
case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_INDICATION):
- printf("%s: Accepting N-CONNECT.ind (local_ref=%u)\n",
- __func__, scu_prim->u.connect.conn_id);
+ LOGP(DMAIN, LOGL_INFO, "Accepting N-CONNECT.ind (local_ref=%u)\n",
+ scu_prim->u.connect.conn_id);
osmo_sccp_tx_conn_resp(scu, scu_prim->u.connect.conn_id,
&scu_prim->u.connect.called_addr,
data, data_len);
break;
case OSMO_PRIM(OSMO_SCU_PRIM_N_DATA, PRIM_OP_INDICATION):
- printf("%s: Echoing N-DATA.ind (local_ref=%u)\n",
- __func__, scu_prim->u.data.conn_id);
+ LOGP(DMAIN, LOGL_INFO, "Echoing N-DATA.ind (local_ref=%u)\n",
+ scu_prim->u.data.conn_id);
osmo_sccp_tx_data(scu, scu_prim->u.data.conn_id,
data, data_len);
break;
case OSMO_PRIM(OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION):
- printf("%s: Echoing N-UNITDATA.ind\n", __func__);
+ LOGP(DMAIN, LOGL_INFO, "Echoing N-UNITDATA.ind\n");
osmo_sccp_tx_unitdata(scu, &scu_prim->u.unitdata.called_addr,
&scu_prim->u.unitdata.calling_addr,
data, data_len);
break;
default:
- printf("%s: Unknown primitive %u:%u\n", __func__,
- oph->primitive, oph->operation);
+ LOGP(DMAIN, LOGL_NOTICE, "Unknown primitive %u:%u\n",
+ oph->primitive, oph->operation);
break;
}
msgb_free(oph->msg);
@@ -87,21 +87,21 @@ static int callback_prim_cb(struct osmo_prim_hdr *oph, void *_scu)
switch (OSMO_PRIM_HDR(&scu_prim->oph)) {
case OSMO_PRIM(OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION):
- printf("%s: N-UNITDATA.ind: Connecting back to sender\n", __func__);
+ LOGP(DMAIN, LOGL_INFO, "N-UNITDATA.ind: Connecting back to sender\n");
osmo_sccp_tx_conn_req(scu, conn_id++,
&scu_prim->u.unitdata.called_addr,
&scu_prim->u.unitdata.calling_addr,
data, data_len);
break;
case OSMO_PRIM(OSMO_SCU_PRIM_N_DATA, PRIM_OP_INDICATION):
- printf("%s: Echoing N-DATA.ind (local_ref=%u)\n",
- __func__, scu_prim->u.data.conn_id);
+ LOGP(DMAIN, LOGL_INFO, "Echoing N-DATA.ind (local_ref=%u)\n",
+ scu_prim->u.data.conn_id);
osmo_sccp_tx_data(scu, scu_prim->u.data.conn_id,
data, data_len);
break;
default:
- printf("%s: Unknown primitive %u:%u\n", __func__,
- oph->primitive, oph->operation);
+ LOGP(DMAIN, LOGL_NOTICE, "Unknown primitive %u:%u\n",
+ oph->primitive, oph->operation);
break;
}
msgb_free(oph->msg);