logging: Replace remaining fprintf() calls with libosmocore logging

Change-Id: I2a772b3180131923d4e2ee7311670b938cb50fe0
changes/75/26475/2
Harald Welte 10 months ago
parent a9d7ad1175
commit 7293e7bcec
  1. 9
      src/bankd/bankd_pcsc.c
  2. 5
      src/bankd/driver_core.c
  3. 7
      src/bankd/driver_pcsc.c
  4. 6
      src/client/remsim_client.c
  5. 2
      src/client/remsim_client_main.c
  6. 8
      src/client/user_simtrace2.c
  7. 7
      src/rspro_util.c

@ -102,14 +102,16 @@ static void cb2(int c, void *data)
regex_t compiled_name;
int rc;
printf("PC/SC slot name: %u/%u -> regex '%s'\n", sn->slot.bank_id, sn->slot.slot_nr, sn->name_regex);
LOGP(DMAIN, LOGL_INFO, "PC/SC slot name: %u/%u -> regex '%s'\n",
sn->slot.bank_id, sn->slot.slot_nr, sn->name_regex);
memset(&compiled_name, 0, sizeof(compiled_name));
rc = regcomp(&compiled_name, sn->name_regex, REG_EXTENDED);
if (rc != 0) {
char *errmsg = get_regerror(sn, rc, &compiled_name);
fprintf(stderr, "Error compiling regex '%s': %s - Ignoring\n", sn->name_regex, errmsg);
LOGP(DMAIN, LOGL_ERROR, "Error compiling regex '%s': %s - Ignoring\n",
sn->name_regex, errmsg);
talloc_free(errmsg);
talloc_free(sn);
} else {
@ -141,7 +143,8 @@ int bankd_pcsc_read_slotnames(struct bankd *bankd, const char *csv_file)
while ((bytes_read = fread(buf, 1, sizeof(buf), fp)) > 0) {
if (csv_parse(&p, buf, bytes_read, cb1, cb2, &ps) != bytes_read) {
fprintf(stderr, "Error parsing CSV: %s\n", csv_strerror(csv_error(&p)));
LOGP(DMAIN, LOGL_FATAL, "Error parsing bankd PC/SC CSV: %s\n",
csv_strerror(csv_error(&p)));
fclose(fp);
return -1;
}

@ -28,6 +28,7 @@
#include <osmocom/core/linuxlist.h>
#include "internal.h"
#include "debug.h"
static LLIST_HEAD(g_card_reader_drivers);
static LLIST_HEAD(g_card_readers);
@ -46,7 +47,7 @@ struct card_reader *card_reader_alloc(void *ctx, const char *name,
llist_add(&cr->list, &g_card_readers);
printf("allocated reader '%s'\n", cr->name);
LOGP(DMAIN, LOGL_INFO, "allocated reader '%s'\n", cr->name);
return cr;
}
@ -78,7 +79,7 @@ void card_readers_probe(void *ctx)
struct card_reader_driver *drv;
llist_for_each_entry(drv, &g_card_reader_drivers, list) {
printf("probing driver '%s' for drivers\n", drv->name);
LOGP(DMAIN, LOGL_INFO, "probing driver '%s' for drivers\n", drv->name);
drv->ops->probe(ctx);
}
}

@ -36,13 +36,14 @@
#include <winscard.h>
#include "internal.h"
#include "debug.h"
#define PCSC_ERROR(rv, text) \
if (rv != SCARD_S_SUCCESS) { \
fprintf(stderr, text ": %s (0x%lX)\n", pcsc_stringify_error(rv), rv); \
LOGP(DMAIN, LOGL_ERROR, text ": %s (0x%lX)\n", pcsc_stringify_error(rv), rv); \
goto end; \
} else { \
printf(text ": OK\n\n"); \
LOGP(DMAIN, LOGL_DEBUG, ": OK\n\n"); \
}
static void pcsc_readers_probe(void *ctx)
@ -73,7 +74,7 @@ static void pcsc_readers_probe(void *ctx)
num_readers++;
}
printf("num_readers=%d\n", num_readers);
LOGP(DMAIN, LOGL_DEBUG, "num_readers=%d\n", num_readers);
end:
if (mszReaders)

@ -140,7 +140,7 @@ struct bankd_client *remsim_client_create(void *ctx, const char *name, const cha
bc->main_fi = main_fsm_alloc(bc, bc);
if (!bc->main_fi) {
fprintf(stderr, "Unable to create main client FSM: %s\n", strerror(errno));
LOGP(DMAIN, LOGL_FATAL, "Unable to create main client FSM: %s\n", strerror(errno));
exit(1);
}
@ -158,7 +158,7 @@ struct bankd_client *remsim_client_create(void *ctx, const char *name, const cha
rc = server_conn_fsm_alloc(bc, srvc);
if (rc < 0) {
fprintf(stderr, "Unable to create Server conn FSM: %s\n", strerror(errno));
LOGP(DMAIN, LOGL_FATAL, "Unable to create Server conn FSM: %s\n", strerror(errno));
exit(1);
}
osmo_fsm_inst_change_parent(srvc->fi, bc->main_fi, MF_E_SRVC_LOST);
@ -171,7 +171,7 @@ struct bankd_client *remsim_client_create(void *ctx, const char *name, const cha
memcpy(&bankdc->own_comp_id, &srvc->own_comp_id, sizeof(bankdc->own_comp_id));
rc = server_conn_fsm_alloc(bc, bankdc);
if (rc < 0) {
fprintf(stderr, "Unable to connect bankd conn FSM: %s\n", strerror(errno));
LOGP(DMAIN, LOGL_FATAL, "Unable to connect bankd conn FSM: %s\n", strerror(errno));
exit(1);
}
osmo_fsm_inst_update_id(bankdc->fi, "bankd");

@ -188,7 +188,7 @@ int main(int argc, char **argv)
/* Silently (and portably) reap children. */
if (avoid_zombies() < 0) {
fprintf(stderr, "Unable to silently reap children: %s\n", strerror(errno));
LOGP(DMAIN, LOGL_FATAL, "Unable to silently reap children: %s\n", strerror(errno));
exit(1);
}

@ -404,7 +404,7 @@ int client_user_main(struct bankd_client *bc)
rc = osmo_libusb_init(NULL);
if (rc < 0) {
fprintf(stderr, "libusb initialization failed\n");
LOGP(DMAIN, LOGL_ERROR, "libusb initialization failed\n");
return rc;
}
@ -427,7 +427,7 @@ int client_user_main(struct bankd_client *bc)
transp->usb_async = true;
transp->usb_devh = osmo_libusb_open_claim_interface(NULL, NULL, ifm);
if (!transp->usb_devh) {
fprintf(stderr, "can't open USB device\n");
LOGP(DMAIN, LOGL_ERROR, "can't open USB device\n");
return -1;
}
@ -437,14 +437,14 @@ int client_user_main(struct bankd_client *bc)
rc = libusb_claim_interface(transp->usb_devh, cfg->usb.if_num);
if (rc < 0) {
fprintf(stderr, "can't claim interface %d; rc=%d\n", cfg->usb.if_num, rc);
LOGP(DMAIN, LOGL_ERROR, "can't claim interface %d; rc=%d\n", cfg->usb.if_num, rc);
goto close_exit;
}
rc = osmo_libusb_get_ep_addrs(transp->usb_devh, cfg->usb.if_num, &transp->usb_ep.out,
&transp->usb_ep.in, &transp->usb_ep.irq_in);
if (rc < 0) {
fprintf(stderr, "can't obtain EP addrs; rc=%d\n", rc);
LOGP(DMAIN, LOGL_ERROR, "can't obtain EP addrs; rc=%d\n", rc);
goto close_exit;
}

@ -33,6 +33,7 @@
#include <osmocom/rspro/RsproPDU.h>
#include "rspro_util.h"
#include "debug.h"
#define ASN_ALLOC_COPY(out, in) \
do { \
@ -69,7 +70,7 @@ struct msgb *rspro_enc_msg(RsproPDU_t *pdu)
msg->l2h = msg->data;
rval = der_encode_to_buffer(&asn_DEF_RsproPDU, pdu, msgb_data(msg), msgb_tailroom(msg));
if (rval.encoded < 0) {
fprintf(stderr, "Failed to encode %s\n", rval.failed_type->name);
LOGP(DRSPRO, LOGL_ERROR, "Failed to encode %s\n", rval.failed_type->name);
msgb_free(msg);
return NULL;
}
@ -86,10 +87,10 @@ RsproPDU_t *rspro_dec_msg(struct msgb *msg)
RsproPDU_t *pdu = NULL;
asn_dec_rval_t rval;
//printf("decoding %s\n", msgb_hexdump(msg));
LOGP(DRSPRO, LOGL_DEBUG, "decoding %s\n", msgb_hexdump(msg));
rval = ber_decode(NULL, &asn_DEF_RsproPDU, (void **) &pdu, msgb_l2(msg), msgb_l2len(msg));
if (rval.code != RC_OK) {
fprintf(stderr, "Failed to decode: %d. Consumed %zu of %u bytes\n",
LOGP(DRSPRO, LOGL_ERROR, "Failed to decode: %d. Consumed %zu of %u bytes\n",
rval.code, rval.consumed, msgb_length(msg));
return NULL;
}

Loading…
Cancel
Save