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

mobile: Switch from printf to LOGP statements

Add a mobile application logging category and replace printf with
a LOGP. The code is sadly still using exit in the middle of handling.

Change-Id: I71e7f6e6375a485b45bad76ada2be17b0901577d
---
M src/host/layer23/include/osmocom/bb/common/logging.h
M src/host/layer23/src/common/logging.c
M src/host/layer23/src/mobile/app_mobile.c
M src/host/layer23/src/mobile/gsm322.c
M src/host/layer23/src/mobile/main.c
5 files changed, 19 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/07/4907/1

diff --git a/src/host/layer23/include/osmocom/bb/common/logging.h 
b/src/host/layer23/include/osmocom/bb/common/logging.h
index 3efa57a..efe493d 100644
--- a/src/host/layer23/include/osmocom/bb/common/logging.h
+++ b/src/host/layer23/include/osmocom/bb/common/logging.h
@@ -22,6 +22,7 @@
        DSUM,
        DSIM,
        DGPS,
+       DMOB,
 };
 
 extern const struct log_info log_info;
diff --git a/src/host/layer23/src/common/logging.c 
b/src/host/layer23/src/common/logging.c
index d8fd076..3b761ef 100644
--- a/src/host/layer23/src/common/logging.c
+++ b/src/host/layer23/src/common/logging.c
@@ -127,6 +127,12 @@
                .color = "\033[1;35m",
                .enabled = 1, .loglevel = LOGL_DEBUG,
        },
+       [DMOB] = {
+               .name = "DMOB",
+               .description = "Mobile",
+               .color = "\033[1;35m",
+               .enabled = 1, .loglevel = LOGL_DEBUG,
+       },
 };
 
 const struct log_info log_info = {
diff --git a/src/host/layer23/src/mobile/app_mobile.c 
b/src/host/layer23/src/mobile/app_mobile.c
index e3e948f..43631f3 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -97,7 +97,7 @@
 
                /* waiting for reset after shutdown */
                if (ms->shutdown == 2) {
-                       printf("MS '%s' has been resetted\n", ms->name);
+                       LOGP(DMOB, LOGL_NOTICE, "MS '%s' has been resetted\n", 
ms->name);
                        ms->shutdown = 3;
                        break;
                }
@@ -175,7 +175,7 @@
        }
        vty_notify(ms, NULL);
        vty_notify(ms, "Power off!\n");
-       printf("Power off! (MS %s)\n", ms->name);
+       LOGP(DMOB, LOGL_NOTICE, "Power off! (MS %s)\n", ms->name);
 
        return 0;
 }
@@ -212,7 +212,7 @@
 
        rc = layer2_open(ms, ms->settings.layer2_socket_path);
        if (rc < 0) {
-               fprintf(stderr, "Failed during layer2_open()\n");
+               LOGP(DMOB, LOGL_ERROR, "Failed during layer2_open()\n");
                ms->l2_wq.bfd.fd = -1;
                mobile_exit(ms, 1);
                return rc;
@@ -234,14 +234,14 @@
        ms->started = 0;
 
        if (!strcmp(ms->settings.imei, "000000000000000")) {
-               printf("***\nWarning: Mobile '%s' has default IMEI: %s\n",
+               LOGP(DMOB, LOGL_NOTICE, "***\nWarning: Mobile '%s' has default 
IMEI: %s\n",
                        ms->name, ms->settings.imei);
-               printf("This could relate your identitiy to other users with "
+               LOGP(DMOB, LOGL_NOTICE, "This could relate your identitiy to 
other users with "
                        "default IMEI.\n***\n");
        }
 
        l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
-       printf("Mobile '%s' initialized, please start phone now!\n", ms->name);
+       LOGP(DMOB, LOGL_NOTICE, "Mobile '%s' initialized, please start phone 
now!\n", ms->name);
        return 0;
 }
 
@@ -253,7 +253,7 @@
 
        ms = talloc_zero(l23_ctx, struct osmocom_ms);
        if (!ms) {
-               fprintf(stderr, "Failed to allocate MS\n");
+               LOGP(DMOB, LOGL_ERROR, "Failed to allocate MS: %s\n", name);
                return NULL;
        }
 
diff --git a/src/host/layer23/src/mobile/gsm322.c 
b/src/host/layer23/src/mobile/gsm322.c
index 91729d8..6de8bec 100644
--- a/src/host/layer23/src/mobile/gsm322.c
+++ b/src/host/layer23/src/mobile/gsm322.c
@@ -3584,7 +3584,7 @@
                gsm322_sync_to_cell(cs, NULL, 0);
                cs->si = cs->list[cs->arfci].sysinfo;
                if (!cs->si) {
-                       printf("No SI when ret.idle, please fix!\n");
+                       LOGP(DCS, LOGL_FATAL, "No SI when ret.idle, please 
fix!\n");
                        exit(0L);
                }
 
@@ -3670,7 +3670,7 @@
                gsm_print_arfcn(cs->arfcn));
        cs->si = cs->list[cs->arfci].sysinfo;
        if (!cs->si) {
-               printf("No SI when leaving idle, please fix!\n");
+               LOGP(DCS, LOGL_FATAL, "No SI when leaving idle, please fix!\n");
                exit(0L);
        }
        cs->sync_retries = SYNC_RETRIES;
@@ -3700,7 +3700,7 @@
                gsm_print_arfcn(cs->arfcn));
        cs->si = cs->list[cs->arfci].sysinfo;
        if (!cs->si) {
-               printf("No SI when leaving idle, please fix!\n");
+               LOGP(DCS, LOGL_FATAL, "No SI when leaving idle, please fix!\n");
                exit(0L);
        }
        cs->sync_retries = SYNC_RETRIES;
@@ -4637,7 +4637,7 @@
                cs->arfci = arfcn2index(cs->arfcn);
                cs->si = cs->list[cs->arfci].sysinfo;
                if (!cs->si) {
-                       printf("No SI after neighbour scan, please fix!\n");
+                       LOGP(DNB, LOGL_FATAL, "No SI after neighbour scan, 
please fix!\n");
                        exit(0L);
                }
                LOGP(DNB, LOGL_INFO, "Syncing back to serving cell\n");
diff --git a/src/host/layer23/src/mobile/main.c 
b/src/host/layer23/src/mobile/main.c
index 91ed341..8921bd8 100644
--- a/src/host/layer23/src/mobile/main.c
+++ b/src/host/layer23/src/mobile/main.c
@@ -70,7 +70,7 @@
 
 
 const char *debug_default =
-       "DCS:DNB:DPLMN:DRR:DMM:DSIM:DCC:DMNCC:DSS:DLSMS:DPAG:DSUM:DSAP:DGPS";
+       
"DCS:DNB:DPLMN:DRR:DMM:DSIM:DCC:DMNCC:DSS:DLSMS:DPAG:DSUM:DSAP:DGPS:DMOB";
 
 const char *openbsc_copyright =
        "Copyright (C) 2010-2015 Andreas Eversberg, Sylvain Munaut, Holger 
Freyther, Harald Welte\n"

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I71e7f6e6375a485b45bad76ada2be17b0901577d
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther <[email protected]>

Reply via email to