From 3ce7454105beaa41b41639b46bc8e0aeb09f846f Mon Sep 17 00:00:00 2001 From: faluco Date: Wed, 17 Feb 2021 17:35:20 +0100 Subject: [PATCH] - Remove old loggers from ue_stack_lte, ue gw. - Remove old loggers setting up for these classes. --- srsenb/src/stack/gnb_stack_nr.cc | 2 +- srsue/hdr/stack/ue_stack_lte.h | 40 +++++++++++----------------- srsue/hdr/stack/upper/gw.h | 5 ++-- srsue/src/stack/ue_stack_lte.cc | 29 ++++---------------- srsue/src/stack/upper/gw.cc | 3 +-- srsue/src/ue.cc | 8 +++--- srsue/test/ttcn3/hdr/ttcn3_ue.h | 3 +-- srsue/test/ttcn3/src/ttcn3_syssim.cc | 4 +-- srsue/test/ttcn3/src/ttcn3_ue.cc | 6 ++--- srsue/test/upper/gw_test.cc | 29 +++++--------------- srsue/test/upper/nas_test.cc | 12 +-------- 11 files changed, 41 insertions(+), 100 deletions(-) diff --git a/srsenb/src/stack/gnb_stack_nr.cc b/srsenb/src/stack/gnb_stack_nr.cc index 63d5f481b..7e62c4287 100644 --- a/srsenb/src/stack/gnb_stack_nr.cc +++ b/srsenb/src/stack/gnb_stack_nr.cc @@ -83,7 +83,7 @@ int gnb_stack_nr::init(const srsenb::stack_args_t& args_, const rrc_nr_cfg_t& rr m_sdap->init(m_pdcp.get(), nullptr, m_gw.get()); - m_gw->init(args.coreless.gw_args, logger, this); + m_gw->init(args.coreless.gw_args, this); char* err_str = nullptr; if (m_gw->setup_if_addr(5, args.coreless.drb_lcid, diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index d3031f8c2..aff796265 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -57,13 +57,12 @@ public: std::string get_type() final; - int init(const stack_args_t& args_, srslte::logger* logger_); - int init(const stack_args_t& args_, srslte::logger* logger_, phy_interface_stack_lte* phy_, gw_interface_stack* gw_); - int init(const stack_args_t& args_, - srslte::logger* logger_, - phy_interface_stack_lte* phy_, - phy_interface_stack_nr* phy_nr_, - gw_interface_stack* gw_); + int init(const stack_args_t& args_); + int init(const stack_args_t& args_, phy_interface_stack_lte* phy_, gw_interface_stack* gw_); + int init(const stack_args_t& args_, + phy_interface_stack_lte* phy_, + phy_interface_stack_nr* phy_nr_, + gw_interface_stack* gw_); bool switch_on() final; bool switch_off() final; bool is_registered() final; @@ -168,13 +167,6 @@ private: srslte::tti_point current_tti; // UE stack logging - srslte::logger* logger = nullptr; - srslte::log_ref mac_log{"MAC"}; - srslte::log_ref rlc_log{"RLC"}; - srslte::log_ref pdcp_log{"PDCP"}; - srslte::log_ref rrc_log{"RRC"}; - srslte::log_ref usim_log{"USIM"}; - srslte::log_ref nas_log{"NAS"}; srslog::basic_logger& stack_logger; srslog::basic_logger& mac_logger; srslog::basic_logger& rlc_logger; @@ -184,8 +176,8 @@ private: srslog::basic_logger& nas_logger; // RAT-specific interfaces - phy_interface_stack_lte* phy = nullptr; - gw_interface_stack* gw = nullptr; + phy_interface_stack_lte* phy = nullptr; + gw_interface_stack* gw = nullptr; phy_interface_stack_nr* phy_nr = nullptr; // Thread @@ -198,14 +190,14 @@ private: srslte::tprof tti_tprof; // stack components - srsue::mac mac; - srslte::mac_pcap mac_pcap; - srslte::nas_pcap nas_pcap; - srslte::rlc rlc; - srslte::pdcp pdcp; - srsue::rrc rrc; - srsue::mac_nr mac_nr; - srsue::rrc_nr rrc_nr; + srsue::mac mac; + srslte::mac_pcap mac_pcap; + srslte::nas_pcap nas_pcap; + srslte::rlc rlc; + srslte::pdcp pdcp; + srsue::rrc rrc; + srsue::mac_nr mac_nr; + srsue::rrc_nr rrc_nr; srsue::nas nas; std::unique_ptr usim; diff --git a/srsue/hdr/stack/upper/gw.h b/srsue/hdr/stack/upper/gw.h index 00da23f97..251c3b3cc 100644 --- a/srsue/hdr/stack/upper/gw.h +++ b/srsue/hdr/stack/upper/gw.h @@ -41,7 +41,7 @@ class gw : public gw_interface_stack, public srslte::thread { public: gw(); - int init(const gw_args_t& args_, srslte::logger* logger_, stack_interface_gw* stack); + int init(const gw_args_t& args_, stack_interface_gw* stack); void stop(); void get_metrics(gw_metrics_t& m, const uint32_t nof_tti); @@ -69,8 +69,7 @@ public: private: static const int GW_THREAD_PRIO = -1; - stack_interface_gw* stack = nullptr; - srslte::logger* old_logger = nullptr; + stack_interface_gw* stack = nullptr; gw_args_t args = {}; diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 7cf049b2b..2c305c246 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -25,7 +25,6 @@ namespace srsue { ue_stack_lte::ue_stack_lte(srslog::sink& log_sink) : running(false), args(), - logger(nullptr), stack_logger(srslog::fetch_basic_logger("STCK", log_sink, false)), mac_logger(srslog::fetch_basic_logger("MAC", log_sink)), rlc_logger(srslog::fetch_basic_logger("RLC", log_sink, false)), @@ -65,37 +64,32 @@ std::string ue_stack_lte::get_type() } int ue_stack_lte::init(const stack_args_t& args_, - srslte::logger* logger_, phy_interface_stack_lte* phy_, phy_interface_stack_nr* phy_nr_, gw_interface_stack* gw_) { phy_nr = phy_nr_; - if (init(args_, logger_, phy_, gw_)) { + if (init(args_, phy_, gw_)) { return SRSLTE_ERROR; } return SRSLTE_SUCCESS; } -int ue_stack_lte::init(const stack_args_t& args_, - srslte::logger* logger_, - phy_interface_stack_lte* phy_, - gw_interface_stack* gw_) +int ue_stack_lte::init(const stack_args_t& args_, phy_interface_stack_lte* phy_, gw_interface_stack* gw_) { phy = phy_; gw = gw_; - if (init(args_, logger_)) { + if (init(args_)) { return SRSLTE_ERROR; } return SRSLTE_SUCCESS; } -int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_) +int ue_stack_lte::init(const stack_args_t& args_) { - args = args_; - logger = logger_; + args = args_; // init own log stack_logger.set_level(srslog::str_to_basic_level(args.log.stack_level)); @@ -103,29 +97,16 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_) byte_buffer_pool::get_instance()->enable_logger(true); // init layer logs - srslte::logmap::register_log(std::unique_ptr{new srslte::log_filter{"MAC", logger, true}}); - mac_log->set_level(args.log.mac_level); - mac_log->set_hex_limit(args.log.mac_hex_limit); mac_logger.set_level(srslog::str_to_basic_level(args.log.mac_level)); mac_logger.set_hex_dump_max_size(args.log.mac_hex_limit); - rlc_log->set_level(args.log.rlc_level); - rlc_log->set_hex_limit(args.log.rlc_hex_limit); rlc_logger.set_level(srslog::str_to_basic_level(args.log.rlc_level)); rlc_logger.set_hex_dump_max_size(args.log.rlc_hex_limit); - pdcp_log->set_level(args.log.pdcp_level); - pdcp_log->set_hex_limit(args.log.pdcp_hex_limit); pdcp_logger.set_level(srslog::str_to_basic_level(args.log.pdcp_level)); pdcp_logger.set_hex_dump_max_size(args.log.pdcp_hex_limit); - rrc_log->set_level(args.log.rrc_level); - rrc_log->set_hex_limit(args.log.rrc_hex_limit); rrc_logger.set_level(srslog::str_to_basic_level(args.log.rrc_level)); rrc_logger.set_hex_dump_max_size(args.log.rrc_hex_limit); - usim_log->set_level(args.log.usim_level); - usim_log->set_hex_limit(args.log.usim_hex_limit); usim_logger.set_level(srslog::str_to_basic_level(args.log.usim_level)); usim_logger.set_hex_dump_max_size(args.log.usim_hex_limit); - nas_log->set_level(args.log.nas_level); - nas_log->set_hex_limit(args.log.nas_hex_limit); nas_logger.set_level(srslog::str_to_basic_level(args.log.nas_level)); nas_logger.set_hex_dump_max_size(args.log.nas_hex_limit); diff --git a/srsue/src/stack/upper/gw.cc b/srsue/src/stack/upper/gw.cc index 80e647140..d34772213 100644 --- a/srsue/src/stack/upper/gw.cc +++ b/srsue/src/stack/upper/gw.cc @@ -27,10 +27,9 @@ namespace srsue { gw::gw() : thread("GW"), logger(srslog::fetch_basic_logger("GW", false)), tft_matcher(logger) {} -int gw::init(const gw_args_t& args_, srslte::logger* logger_, stack_interface_gw* stack_) +int gw::init(const gw_args_t& args_, stack_interface_gw* stack_) { stack = stack_; - old_logger = logger_; args = args_; run_enable = true; diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index d9c6e31bd..7ac716b27 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -18,8 +18,8 @@ #include "srslte/radio/radio_null.h" #include "srslte/srslte.h" #include "srsue/hdr/phy/phy.h" -#include "srsue/hdr/stack/ue_stack_lte.h" #include "srsue/hdr/phy/vnf_phy_nr.h" +#include "srsue/hdr/stack/ue_stack_lte.h" #include "srsue/hdr/stack/ue_stack_nr.h" #include #include @@ -105,12 +105,12 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) ret = SRSLTE_ERROR; } - if (lte_stack->init(args.stack, old_logger, lte_phy.get(), lte_phy.get(), gw_ptr.get())) { + if (lte_stack->init(args.stack, lte_phy.get(), gw_ptr.get())) { srslte::console("Error initializing stack.\n"); ret = SRSLTE_ERROR; } - if (gw_ptr->init(args.gw, old_logger, lte_stack.get())) { + if (gw_ptr->init(args.gw, lte_stack.get())) { srslte::console("Error initializing GW.\n"); ret = SRSLTE_ERROR; } @@ -143,7 +143,7 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) return SRSLTE_ERROR; } - if (gw_ptr->init(args.gw, old_logger, nr_stack.get())) { + if (gw_ptr->init(args.gw, nr_stack.get())) { srslte::console("Error initializing GW.\n"); return SRSLTE_ERROR; } diff --git a/srsue/test/ttcn3/hdr/ttcn3_ue.h b/srsue/test/ttcn3/hdr/ttcn3_ue.h index e997e534a..34590644c 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_ue.h +++ b/srsue/test/ttcn3/hdr/ttcn3_ue.h @@ -24,7 +24,7 @@ public: virtual ~ttcn3_ue(); - int init(all_args_t args, srslte::logger* logger_, syssim_interface_phy* syssim_, const std::string tc_name_); + int init(all_args_t args, syssim_interface_phy* syssim_, const std::string tc_name_); void stop(); @@ -76,7 +76,6 @@ private: std::unique_ptr stack; // Generic logger members - srslte::logger* old_logger = nullptr; srslog::basic_logger& logger; test_loop_mode_state_t test_loop_mode = TEST_LOOP_INACTIVE; diff --git a/srsue/test/ttcn3/src/ttcn3_syssim.cc b/srsue/test/ttcn3/src/ttcn3_syssim.cc index dc10f3487..c6c417ff4 100644 --- a/srsue/test/ttcn3/src/ttcn3_syssim.cc +++ b/srsue/test/ttcn3/src/ttcn3_syssim.cc @@ -57,7 +57,7 @@ ttcn3_syssim::ttcn3_syssim(srslte::logger& logger_file_, srslte::logger& logger_ signal_handler(&running), timer_handler(create_tti_timer(), [&](uint64_t res) { new_tti_indication(res); }) { - if (ue->init(all_args_t{}, old_logger, this, "INIT_TEST") != SRSLTE_SUCCESS) { + if (ue->init(all_args_t{}, this, "INIT_TEST") != SRSLTE_SUCCESS) { ue->stop(); fprintf(stderr, "Couldn't initialize UE.\n"); } @@ -445,7 +445,7 @@ void ttcn3_syssim::tc_start(const char* name) local_args.stack.pcap.nas_filename = get_filename_with_tc_name(args.stack.pcap.nas_filename, run_id, tc_name); // bring up UE - if (ue->init(local_args, old_logger, this, tc_name)) { + if (ue->init(local_args, this, tc_name)) { ue->stop(); std::string err("Couldn't initialize UE."); logger.error("%s", err.c_str()); diff --git a/srsue/test/ttcn3/src/ttcn3_ue.cc b/srsue/test/ttcn3/src/ttcn3_ue.cc index a7f70b4aa..36db97752 100644 --- a/srsue/test/ttcn3/src/ttcn3_ue.cc +++ b/srsue/test/ttcn3/src/ttcn3_ue.cc @@ -22,10 +22,8 @@ SRSLTE_API char* srslte_get_build_mode(); ttcn3_ue::ttcn3_ue() : logger(srslog::fetch_basic_logger("UE", false)), tft_matcher(logger) {} -int ttcn3_ue::init(all_args_t args, srslte::logger* logger_, syssim_interface_phy* syssim_, const std::string tc_name_) +int ttcn3_ue::init(all_args_t args, syssim_interface_phy* syssim_, const std::string tc_name_) { - old_logger = logger_; - // Init UE log logger.set_level(srslog::basic_levels::info); logger.set_hex_dump_max_size(128); @@ -79,7 +77,7 @@ int ttcn3_ue::init(all_args_t args, srslte::logger* logger_, syssim_interface_ph return SRSLTE_ERROR; } - if (stack->init(args.stack, old_logger, phy.get(), this)) { + if (stack->init(args.stack, phy.get(), this)) { srslte::console("Error initializing stack.\n"); return SRSLTE_ERROR; } diff --git a/srsue/test/upper/gw_test.cc b/srsue/test/upper/gw_test.cc index 573b46a23..611251f45 100644 --- a/srsue/test/upper/gw_test.cc +++ b/srsue/test/upper/gw_test.cc @@ -30,34 +30,13 @@ public: int gw_change_lcid_test() { - - // Setup logging. - srslog::sink* log_sink = srslog::create_stdout_sink(); - if (!log_sink) { - return SRSLTE_ERROR; - } - - srslog::log_channel* chan = srslog::create_log_channel("main_channel", *log_sink); - if (!chan) { - return SRSLTE_ERROR; - } - - srslte::srslog_wrapper log_wrapper(*chan); - - srslte::log_filter log; - log.init("TEST ", &log_wrapper); - log.set_level("debug"); - log.set_hex_limit(10000); - - srslog::init(); - srsue::gw_args_t gw_args; gw_args.tun_dev_name = "tun1"; gw_args.log.gw_level = "debug"; gw_args.log.gw_hex_limit = 100000; test_stack_dummy stack; srsue::gw gw; - gw.init(gw_args, &log_wrapper, &stack); + gw.init(gw_args, &stack); uint32_t eps_bearer_id = 5; uint32_t non_existing_eps_bearer_id = 23; @@ -70,7 +49,8 @@ int gw_change_lcid_test() eps_bearer_id, old_lcid, LIBLTE_MME_PDN_TYPE_IPV4, htonl(inet_addr("192.168.56.32")), nullptr, err_str); if (rtn != SRSLTE_SUCCESS) { - log.error("Failed to setup GW interface. Not possible to test function. Try to execute with sudo rights."); + srslog::fetch_basic_logger("TEST", false) + .error("Failed to setup GW interface. Not possible to test function. Try to execute with sudo rights."); gw.stop(); return SRSLTE_SUCCESS; } @@ -83,6 +63,9 @@ int gw_change_lcid_test() int main(int argc, char** argv) { + srslog::init(); + TESTASSERT(gw_change_lcid_test() == SRSLTE_SUCCESS); + return SRSLTE_SUCCESS; } diff --git a/srsue/test/upper/nas_test.cc b/srsue/test/upper/nas_test.cc index da171119b..ccef5d163 100644 --- a/srsue/test/upper/nas_test.cc +++ b/srsue/test/upper/nas_test.cc @@ -67,8 +67,6 @@ uint8_t deactivate_eps_bearer_pdu[] = {0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, uint16 mcc = 61441; uint16 mnc = 65281; -static srslte::logger* g_logger = nullptr; - using namespace srslte; namespace srslte { @@ -312,7 +310,7 @@ int mme_attach_request_test() gw_args.log.gw_level = "debug"; gw_args.log.gw_hex_limit = 100000; - gw.init(gw_args, g_logger, &stack); + gw.init(gw_args, &stack); stack.init(&nas); // trigger test stack.switch_on(); @@ -475,11 +473,6 @@ int dedicated_eps_bearer_test() int main(int argc, char** argv) { // Setup logging. - srslog::sink& log_sink = srslog::fetch_stdout_sink(); - srslog::log_channel* chan = srslog::create_log_channel("mme_attach_request_test", log_sink); - srslte::srslog_wrapper log_wrapper(*chan); - g_logger = &log_wrapper; - auto& rrc_logger = srslog::fetch_basic_logger("RRC", false); rrc_logger.set_level(srslog::basic_levels::debug); rrc_logger.set_hex_dump_max_size(100000); @@ -496,9 +489,6 @@ int main(int argc, char** argv) // Start the log backend. srslog::init(); - srslte::logmap::set_default_log_level(LOG_LEVEL_DEBUG); - srslte::logmap::set_default_hex_limit(100000); - if (security_command_test()) { printf("Security command test failed.\n"); return -1;