This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-trx/+/16665 ) Change subject: uhd: Introduce UHD log category and support UHD >=3.11 logging framework ...................................................................... uhd: Introduce UHD log category and support UHD >=3.11 logging framework Change-Id: I36f1ff7d425a2144fb512ff393af02741eb4a3d4 --- M CommonLibs/Logger.h M CommonLibs/debug.c M CommonLibs/debug.h M Transceiver52M/device/uhd/UHDDevice.cpp 4 files changed, 58 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/65/16665/1 diff --git a/CommonLibs/Logger.h b/CommonLibs/Logger.h index ab72303..b752e51 100644 --- a/CommonLibs/Logger.h +++ b/CommonLibs/Logger.h @@ -58,6 +58,9 @@ #define LOGLV(category, level) \ Log(category, level, __BASE_FILE__, __LINE__).get() << "[tid=" << pthread_self() << "] " +#define LOGSRC(category, level, file, line) \ + Log(category, level, file, line).get() << "[tid=" << pthread_self() << "] " + #define LOGCHAN(chan, category, level) \ Log(category, LOGL_##level, __BASE_FILE__, __LINE__).get() << "[tid=" << pthread_self() << "][chan=" << chan << "] " diff --git a/CommonLibs/debug.c b/CommonLibs/debug.c index cc5be44..ee5270d 100644 --- a/CommonLibs/debug.c +++ b/CommonLibs/debug.c @@ -71,6 +71,12 @@ .color = NULL, .enabled = 1, .loglevel = LOGL_NOTICE, }, + [DUHD] = { + .name = "DUHD", + .description = "Logging from within libuhd itself", + .color = NULL, + .enabled = 1, .loglevel = LOGL_NOTICE, + }, }; const struct log_info log_info = { diff --git a/CommonLibs/debug.h b/CommonLibs/debug.h index 3837329..2b7be23 100644 --- a/CommonLibs/debug.h +++ b/CommonLibs/debug.h @@ -16,6 +16,7 @@ DTRXDUL, DDEV, DLMS, + DUHD, }; #define CLOGC(category, level, fmt, args...) do { \ diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp index 59eb8a7..0a47616 100644 --- a/Transceiver52M/device/uhd/UHDDevice.cpp +++ b/Transceiver52M/device/uhd/UHDDevice.cpp @@ -33,11 +33,12 @@ #include "config.h" #endif -#ifndef USE_UHD_3_11 +#ifdef USE_UHD_3_11 +#include <uhd/utils/log_add.hpp> +#include <uhd/utils/thread.hpp> +#else #include <uhd/utils/msg.hpp> #include <uhd/utils/thread_priority.hpp> -#else -#include <uhd/utils/thread.hpp> #endif #define USRP_TX_AMPL 0.3 @@ -134,23 +135,52 @@ return NULL; } -#ifndef USE_UHD_3_11 +#ifdef USE_UHD_3_11 +static void uhd_log_handler(const uhd::log::logging_info &info) +{ + int level; + + switch(info.verbosity) + { + case uhd::log::trace: + case uhd::log::debug: + level = LOGL_DEBUG; + break; + case uhd::log::info: + level = LOGL_INFO; + break; + case uhd::log::warning: + level = LOGL_NOTICE; + break; + case uhd::log::error: + level = LOGL_ERROR; + break; + case uhd::log::fatal: + level = LOGL_FATAL; + break; + default: + level = LOGL_NOTICE; + } + + LOGSRC(DUHD, level, info.file.c_str(), info.line) << "[" << info.component << "] " << info.message; +} +#else /* Catch and drop underrun 'U' and overrun 'O' messages from stdout since we already report using the logging facility. Direct everything else appropriately. */ -void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg) +static void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg) { switch (type) { case uhd::msg::status: - LOGC(DDEV, INFO) << msg; + LOGC(UHD, INFO) << msg; break; case uhd::msg::warning: - LOGC(DDEV, WARNING) << msg; + LOGC(UHD, NOTICE) << msg; break; case uhd::msg::error: - LOGC(DDEV, ERROR) << msg; + LOGC(UHD, ERROR) << msg; break; case uhd::msg::fastpath: break; @@ -418,6 +448,16 @@ { const char *refstr; + /* Register msg handler. Different APIs depending on UHD version */ +#ifdef USE_UHD_3_11 + uhd::log::add_logger("OsmoTRX", &uhd_log_handler); + uhd::log::set_log_level(uhd::log::debug); + uhd::log::set_console_level(uhd::log::off); + uhd::log::set_logger_level("OsmoTRX", uhd::log::debug); +#else + uhd::msg::register_handler(&uhd_msg_handler); +#endif + // Find UHD devices uhd::device_addr_t addr(args); uhd::device_addrs_t dev_addrs = uhd::device::find(addr); @@ -604,10 +644,6 @@ return false; } -#ifndef USE_UHD_3_11 - // Register msg handler - uhd::msg::register_handler(&uhd_msg_handler); -#endif // Start asynchronous event (underrun check) loop async_event_thrd = new Thread(); async_event_thrd->start((void * (*)(void*))async_event_loop, (void*)this); -- To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/16665 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I36f1ff7d425a2144fb512ff393af02741eb4a3d4 Gerrit-Change-Number: 16665 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191220/9738ca6f/attachment.htm>