share debug.[ch] across all executables

This avoids us having to re-define log_info/log_info_cat for each
program.

Change-Id: I22f4f8a51b91ee09c5be26b1ed1bfca41730c577
This commit is contained in:
Harald Welte 2019-03-03 15:43:07 +01:00
parent e56f2b9b46
commit 61d98e9f3e
6 changed files with 24 additions and 42 deletions

View File

@ -25,15 +25,15 @@ pcsc_test_SOURCES = driver_core.c driver_pcsc.c main.c
pcsc_test_LDADD = $(OSMOCORE_LIBS) \ pcsc_test_LDADD = $(OSMOCORE_LIBS) \
$(PCSC_LIBS) libosmo-rspro.la $(PCSC_LIBS) libosmo-rspro.la
remsim_bankd_SOURCES = bankd_slotmap.c bankd_main.c bankd_pcsc.c remsim_bankd_SOURCES = bankd_slotmap.c bankd_main.c bankd_pcsc.c debug.c
remsim_bankd_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) \ remsim_bankd_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) \
$(PCSC_LIBS) libosmo-rspro.la -lcsv $(PCSC_LIBS) libosmo-rspro.la -lcsv
remsim_client_SOURCES = remsim_client.c remsim_client_fsm.c remsim_client_SOURCES = remsim_client.c remsim_client_fsm.c debug.c
remsim_client_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \ remsim_client_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
libosmo-rspro.la libosmo-rspro.la
simtrace2_remsim_client_SOURCES = simtrace2-remsim_client.c remsim_client_fsm.c \ simtrace2_remsim_client_SOURCES = simtrace2-remsim_client.c remsim_client_fsm.c debug.c \
simtrace2/apdu_dispatch.c \ simtrace2/apdu_dispatch.c \
simtrace2/simtrace2-discovery.c \ simtrace2/simtrace2-discovery.c \
simtrace2/libusb_util.c simtrace2/libusb_util.c

View File

@ -26,6 +26,7 @@
#include <osmocom/rspro/RsproPDU.h> #include <osmocom/rspro/RsproPDU.h>
#include "bankd.h" #include "bankd.h"
#include "debug.h"
#include "rspro_util.h" #include "rspro_util.h"
__thread void *talloc_asn1_ctx; __thread void *talloc_asn1_ctx;
@ -36,19 +37,6 @@ static void *worker_main(void *arg);
* bankd core / main thread * bankd core / main thread
***********************************************************************/ ***********************************************************************/
static const struct log_info_cat default_categories[] = {
[DMAIN] = {
.name = "DMAIN",
.loglevel = LOGL_DEBUG,
.enabled = 1,
},
};
static const struct log_info log_info = {
.cat = default_categories,
.num_cat = ARRAY_SIZE(default_categories),
};
int asn_debug; int asn_debug;
static void bankd_init(struct bankd *bankd) static void bankd_init(struct bankd *bankd)

16
src/debug.c Normal file
View File

@ -0,0 +1,16 @@
#include <osmocom/core/logging.h>
#include <osmocom/core/utils.h>
#include "debug.h"
static const struct log_info_cat default_categories[] = {
[DMAIN] = {
.name = "DMAIN",
.loglevel = LOGL_DEBUG,
.enabled = 1,
},
};
const struct log_info log_info = {
.cat = default_categories,
.num_cat = ARRAY_SIZE(default_categories),
};

View File

@ -3,3 +3,5 @@
enum { enum {
DMAIN, DMAIN,
}; };
extern const struct log_info log_info;

View File

@ -15,6 +15,7 @@
#include "rspro_util.h" #include "rspro_util.h"
#include "client.h" #include "client.h"
#include "debug.h"
static int bankd_handle_msg(struct bankd_client *bc, struct msgb *msg) static int bankd_handle_msg(struct bankd_client *bc, struct msgb *msg)
{ {
@ -68,19 +69,6 @@ invalid:
return -1; return -1;
} }
static const struct log_info_cat default_categories[] = {
[DMAIN] = {
.name = "DMAIN",
.loglevel = LOGL_DEBUG,
.enabled = 1,
},
};
static const struct log_info log_info = {
.cat = default_categories,
.num_cat = ARRAY_SIZE(default_categories),
};
static struct bankd_client *g_client; static struct bankd_client *g_client;
static void *g_tall_ctx; static void *g_tall_ctx;
void __thread *talloc_asn1_ctx; void __thread *talloc_asn1_ctx;

View File

@ -15,6 +15,7 @@
#include "rspro_util.h" #include "rspro_util.h"
#include "client.h" #include "client.h"
#include "debug.h"
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
@ -619,19 +620,6 @@ static int srvc_handle_rx(struct rspro_server_conn *srvc, const RsproPDU_t *pdu)
} }
static const struct log_info_cat default_categories[] = {
[DMAIN] = {
.name = "DMAIN",
.loglevel = LOGL_DEBUG,
.enabled = 1,
},
};
static const struct log_info log_info = {
.cat = default_categories,
.num_cat = ARRAY_SIZE(default_categories),
};
static void print_welcome(void) static void print_welcome(void)
{ {
printf("simtrace2-remsim-client - Remote SIM card client for SIMtrace\n" printf("simtrace2-remsim-client - Remote SIM card client for SIMtrace\n"