diff --git a/lib/src/phy/common/phy_logger.c b/lib/src/phy/common/phy_logger.c index 09393236a..5a44e1a58 100644 --- a/lib/src/phy/common/phy_logger.c +++ b/lib/src/phy/common/phy_logger.c @@ -46,16 +46,13 @@ void srslte_phy_log_register_handler(void *ctx, phy_log_handler_t handler) { } void srslte_phy_log_print(phy_logger_level_t log_level, const char *format, ...) { + char tmp[256]; va_list args; va_start(args, format); if (phy_log_handler) { - char *args_msg = NULL; - if(vasprintf(&args_msg, format, args) > 0) { - phy_log_handler(log_level, callback_ctx, args_msg); + if(vsnprintf(tmp, 256, format, args) > 0) { + phy_log_handler(log_level, callback_ctx, tmp); } - if (args_msg) { - free(args_msg); - } - } + } va_end(args); } \ No newline at end of file diff --git a/srsue/src/phy/phch_recv.cc b/srsue/src/phy/phch_recv.cc index 7e41c6836..8ab51d90c 100644 --- a/srsue/src/phy/phch_recv.cc +++ b/srsue/src/phy/phch_recv.cc @@ -379,7 +379,9 @@ void phch_recv::run_thread() { Debug("SYNC: state=%s\n", phy_state.to_string()); - log_phy_lib_h->step(tti); + if (log_phy_lib_h) { + log_phy_lib_h->step(tti); + } sf_idx = tti%10; diff --git a/srsue/src/phy/phch_worker.cc b/srsue/src/phy/phch_worker.cc index f44f4f9a0..7f83ac731 100644 --- a/srsue/src/phy/phch_worker.cc +++ b/srsue/src/phy/phch_worker.cc @@ -192,7 +192,9 @@ void phch_worker::set_tti(uint32_t tti_, uint32_t tx_tti_) tti = tti_; tx_tti = tx_tti_; log_h->step(tti); - log_phy_lib_h->step(tti); + if (log_phy_lib_h) { + log_phy_lib_h->step(tti); + } } void phch_worker::set_prach(cf_t *prach_ptr, float prach_power) { diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index 508dd5dfb..3e2454f12 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -143,9 +143,13 @@ bool phy::init(srslte::radio_multi* radio_handler, mac_interface_phy *mac, rrc_i nof_coworkers = SRSLTE_MIN(nof_workers - MAX_WORKERS, MAX_WORKERS); nof_workers = MAX_WORKERS; } - this->log_phy_lib_h = (srslte::log*) log_vec[nof_workers]; - srslte_phy_log_register_handler(this, srslte_phy_handler); - + if (log_vec[nof_workers]) { + this->log_phy_lib_h = (srslte::log*) log_vec[nof_workers]; + srslte_phy_log_register_handler(this, srslte_phy_handler); + } else { + this->log_phy_lib_h = NULL; + } + initiated = false; start(); return true; diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index ae06eae26..e9078a1cd 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -45,7 +45,9 @@ ue::ue() ue::~ue() { for (uint32_t i = 0; i < phy_log.size(); i++) { - delete(phy_log[i]); + if (phy_log[i]) { + delete(phy_log[i]); + } } if (usim) { delete usim; @@ -95,13 +97,17 @@ bool ue::init(all_args_t *args_) { } /* here we add a log layer to handle logging from the phy library*/ - srslte::log_filter *lib_log = new srslte::log_filter; - char tmp[16]; - sprintf(tmp, "PHY_LIB"); - lib_log->init(tmp, logger, true); - phy_log.push_back(lib_log); - ((srslte::log_filter*) phy_log[nof_phy_threads])->set_level(level(args->log.phy_lib_level)); - + if (level(args->log.phy_lib_level) != LOG_LEVEL_NONE) { + srslte::log_filter *lib_log = new srslte::log_filter; + char tmp[16]; + sprintf(tmp, "PHY_LIB"); + lib_log->init(tmp, logger, true); + phy_log.push_back(lib_log); + ((srslte::log_filter*) phy_log[nof_phy_threads])->set_level(level(args->log.phy_lib_level)); + } else { + phy_log.push_back(NULL); + } + mac_log.set_level(level(args->log.mac_level)); rlc_log.set_level(level(args->log.rlc_level)); @@ -112,7 +118,9 @@ bool ue::init(all_args_t *args_) { usim_log.set_level(level(args->log.usim_level)); for (int i=0;iset_hex_limit(args->log.phy_hex_limit); + if (phy_log[i]) { + ((srslte::log_filter*) phy_log[i])->set_hex_limit(args->log.phy_hex_limit); + } } mac_log.set_hex_limit(args->log.mac_hex_limit); rlc_log.set_hex_limit(args->log.rlc_hex_limit);