From 86f3a660896f27c23929d9b1b6a30ebd8a435a83 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 16 Oct 2022 18:35:42 +0200 Subject: [PATCH] some more log statements --- src/isdntap.c | 15 ++++++++++++--- src/log.h | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/isdntap.c b/src/isdntap.c index e0402f3..573c398 100644 --- a/src/isdntap.c +++ b/src/isdntap.c @@ -319,11 +319,16 @@ static int isdntap_q931_rx(struct isdntap_line *line, bool net2user, const uint8 /* now we know the exact B channel used */ /* start B-channel capturing */ ts_b = get_bchan_ts(line, &cstate->chan_id); - if (!ts_b) + if (!ts_b) { + LOGPLI(line, DITAP, LOGL_ERROR, + "Cannot resolve TS for Channel ID\n"); break; + } rc = line->driver->ts_open(ts_b); - if (rc < 0) + if (rc < 0) { + LOGPTS(ts_b, DITAP, LOGL_ERROR, "Cannot open B-channel\n"); break; + } char strbuf[256]; gen_chan_label(strbuf, sizeof(strbuf), cstate); @@ -396,6 +401,7 @@ int isdntap_ts_rx_dchan(struct isdntap_ts *ts, const uint8_t *buf, size_t len, b (is_rx && !ts->line->local_side_is_network)) net2user = true; + LOGPTS(ts, DLINP, LOGL_DEBUG, "%s %s\n", is_rx ? "Rx" : "Tx", osmo_hexdump(buf, len)); isdntap_q921_rx(ts->line, net2user, buf, len); return 0; } @@ -438,7 +444,7 @@ static int isdntap_open_file(struct isdntap_ts *ts, const char *call_label, cons return rc; } - LOGP(DITAP, LOGL_INFO, "Opened file %s\n", buf); + LOGPTS(ts, DITAP, LOGL_INFO, "Opened file %s\n", buf); return rc; } @@ -446,6 +452,8 @@ int isdntap_ts_start_bchan(struct isdntap_ts *ts, const char *call_label) { int fd_rx, fd_tx; + LOGPTS(ts, DITAP, LOGL_INFO, "Starting B-channel recording %s\n", call_label); + osmo_wqueue_init(&ts->output.file.tx, 100); fd_tx = isdntap_open_file(ts, call_label, "tx"); if (fd_tx < 0) @@ -472,6 +480,7 @@ out_cleanup_tx: void isdntap_ts_stop_bchan(struct isdntap_ts *ts) { + LOGPTS(ts, DITAP, LOGL_INFO, "Stopping B-channel recording\n"); /* FIXME: ideally we'd make sure that the write queues are both fully flushed first */ if (ts->output.file.tx.bfd.fd >= 0) { diff --git a/src/log.h b/src/log.h index 13696e9..cbf33f3 100644 --- a/src/log.h +++ b/src/log.h @@ -32,3 +32,9 @@ enum { }; extern const struct log_info log_info; + +#define LOGPLI(li, ss, lvl, fmt, args...) \ + LOGP(ss, lvl, "(%s) " fmt, (li)->name, ## args) + +#define LOGPTS(ts, ss, lvl, fmt, args...) \ + LOGP(ss, lvl, "(%s:%u) " fmt, (ts)->line->name, (ts)->num, ## args)