From 79eca0980d5a2ff6556f1b30004dcf2fa37ced0c Mon Sep 17 00:00:00 2001 From: faluco Date: Mon, 1 Feb 2021 15:14:03 +0100 Subject: [PATCH] - Ported fsm.h to srslog. - Adapted and removed old loggers in tests and code that used fsm.h --- lib/include/srslte/common/fsm.h | 62 +++++++------- lib/test/common/fsm_test.cc | 109 +++++++++++++------------ srsenb/hdr/stack/rrc/rrc.h | 1 - srsenb/src/stack/rrc/rrc.cc | 4 +- srsenb/src/stack/rrc/rrc_mobility.cc | 22 ++--- srsenb/test/upper/rrc_mobility_test.cc | 2 + srsue/src/stack/rrc/phy_controller.cc | 16 ++-- srsue/test/upper/rrc_phy_ctrl_test.cc | 24 +++--- 8 files changed, 123 insertions(+), 117 deletions(-) diff --git a/lib/include/srslte/common/fsm.h b/lib/include/srslte/common/fsm.h index e01382da3..1466fba5e 100644 --- a/lib/include/srslte/common/fsm.h +++ b/lib/include/srslte/common/fsm.h @@ -22,11 +22,11 @@ #include #include -#define otherfsmDebug(f, fmt, ...) f->get_log()->debug("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__) -#define otherfsmInfo(f, fmt, ...) f->get_log()->info("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__) +#define otherfsmDebug(f, fmt, ...) f->get_logger().debug("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__) +#define otherfsmInfo(f, fmt, ...) f->get_logger().info("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__) #define otherfsmWarning(f, fmt, ...) \ - f->get_log()->warning("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__) -#define otherfsmError(f, fmt, ...) f->get_log()->error("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__) + f->get_logger().warning("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__) +#define otherfsmError(f, fmt, ...) f->get_logger().error("FSM \"%s\" - " fmt, get_type_name(*f).c_str(), ##__VA_ARGS__) #define fsmDebug(fmt, ...) otherfsmDebug(this, fmt, ##__VA_ARGS__) #define fsmInfo(fmt, ...) otherfsmInfo(this, fmt, ##__VA_ARGS__) @@ -159,7 +159,7 @@ static auto get_state_recursive(FSM* f) -> disable_if_fsm_state struct state_traits { - static_assert(FSM::template can_hold_state(), "FSM type does not hold provided State\n"); + static_assert(FSM::template can_hold_state(), "FSM type does not hold provided State"); using state_t = State; using is_subfsm = std::integral_constant::value>; @@ -225,7 +225,7 @@ struct apply_first_guard_pass > { // Log Transition if (std::is_same::value) { otherfsmInfo(static_cast(f), - "Event \"%s\" triggered state \"%s\" update\n", + "Event \"%s\" triggered state \"%s\" update", get_type_name().c_str(), get_type_name().c_str()); } else { @@ -250,7 +250,7 @@ struct apply_first_guard_pass > { { if (should_log_unhandled_event(&ev)) { otherfsmDebug(static_cast(f), - "unhandled event caught in state \"%s\": \"%s\"\n", + "unhandled event caught in state \"%s\": \"%s\"", get_type_name().c_str(), get_type_name().c_str()); } @@ -385,7 +385,7 @@ public: struct state_list : public std::tuple { using tuple_base_t = std::tuple; using init_state_t = typename std::decay(std::declval()))>::type; - static_assert(not type_list_contains(), "An FSM cannot contain itself as state\n"); + static_assert(not type_list_contains(), "An FSM cannot contain itself as state"); template state_list(base_fsm_t* f, Args&&... args) : tuple_base_t(std::forward(args)...) @@ -507,7 +507,7 @@ protected: public: static const bool is_nested = false; - explicit fsm_t(srslte::log_ref log_) : log_h(log_) {} + explicit fsm_t(srslog::basic_logger& logger) : logger(logger) {} // Push Events to FSM template @@ -527,9 +527,9 @@ public: return ret; } - void set_fsm_event_log_level(srslte::LOG_LEVEL_ENUM e) { fsm_event_log_level = e; } + void set_fsm_event_log_level(srslog::basic_levels lvl) { log_level = lvl; } - srslte::log_ref get_log() const { return log_h; } + srslog::basic_logger& get_logger() const { return logger; } bool is_trigger_locked() const { return trigger_locked; } @@ -537,18 +537,18 @@ public: template void log_fsm_activity(const char* format, Args&&... args) { - switch (fsm_event_log_level) { - case LOG_LEVEL_DEBUG: - log_h->debug(format, std::forward(args)...); + switch (log_level) { + case srslog::basic_levels::debug: + logger.debug(format, std::forward(args)...); break; - case LOG_LEVEL_INFO: - log_h->info(format, std::forward(args)...); + case srslog::basic_levels::info: + logger.info(format, std::forward(args)...); break; - case LOG_LEVEL_WARNING: - log_h->warning(format, std::forward(args)...); + case srslog::basic_levels::warning: + logger.warning(format, std::forward(args)...); break; - case LOG_LEVEL_ERROR: - log_h->error(format, std::forward(args)...); + case srslog::basic_levels::error: + logger.error(format, std::forward(args)...); break; default: break; @@ -570,9 +570,9 @@ protected: pending_events.emplace_back(std::bind([this](Ev& e) { process_event(std::move(e)); }, std::move(e))); } - srslte::log_ref log_h; - srslte::LOG_LEVEL_ENUM fsm_event_log_level = LOG_LEVEL_INFO; - bool trigger_locked = false; + srslog::basic_logger& logger; + srslog::basic_levels log_level = srslog::basic_levels::info; + bool trigger_locked = false; std::deque > pending_events; }; @@ -593,7 +593,7 @@ public: parent_t* parent_fsm() { return fsm_ptr; } - srslte::log_ref get_log() const { return parent_fsm()->get_log(); } + srslog::basic_logger& get_logger() const { return parent_fsm()->get_logger(); } // Push Events to root FSM template @@ -634,7 +634,7 @@ class proc_fsm_t : public fsm_t using fsm_t::derived; protected: - using fsm_t::log_h; + using fsm_t::logger; public: using base_t = proc_fsm_t; @@ -650,14 +650,14 @@ public: void enter(Derived* f) { if (f->launch_counter > 0) { - f->log_h->warning( - "FSM \"%s\": No result was set for run no. %d\n", get_type_name().c_str(), f->launch_counter); + f->logger.warning( + "FSM \"%s\": No result was set for run no. %d", get_type_name().c_str(), f->launch_counter); } } void enter(Derived* f, const complete_ev& ev) { - f->log_h->info("FSM \"%s\": Finished run no. %d\n", get_type_name().c_str(), f->launch_counter); + f->logger.info("FSM \"%s\": Finished run no. %d", get_type_name().c_str(), f->launch_counter); f->last_result = ev.result; for (auto& func : f->listening_fsms) { func(ev); @@ -668,11 +668,11 @@ public: void exit(Derived* f) { f->launch_counter++; - f->log_h->info("FSM \"%s\": Starting run no. %d\n", get_type_name().c_str(), f->launch_counter); + f->logger.info("FSM \"%s\": Starting run no. %d", get_type_name().c_str(), f->launch_counter); } }; - explicit proc_fsm_t(srslte::log_ref log_) : fsm_t(log_) {} + explicit proc_fsm_t(srslog::basic_logger& logger) : fsm_t(logger) {} bool is_running() const { return not base_t::template is_in_state(); } @@ -711,7 +711,7 @@ public: void enter(FSM* f, const Ev& ev) { if (proc_ptr->is_running()) { - f->get_log()->error("Unable to launch proc1\n"); + f->get_logger().error("Unable to launch proc1"); f->trigger(typename ProcFSM::complete_ev{false}); } proc_ptr->trigger(srslte::proc_launch_ev{ev}); diff --git a/lib/test/common/fsm_test.cc b/lib/test/common/fsm_test.cc index 14f48e1a8..df5d23af2 100644 --- a/lib/test/common/fsm_test.cc +++ b/lib/test/common/fsm_test.cc @@ -20,11 +20,12 @@ struct ev1 {}; struct ev2 {}; std::vector calls; + template -void call_log_helper(State* state, srslte::log_ref log_h, const char* type) +void call_log_helper(State* state, srslog::basic_logger& logger, const char* type) { std::string callname = srslte::get_type_name() + "::" + type; - log_h->info("%s custom called\n", callname.c_str()); + logger.info("%s custom called", callname.c_str()); calls.push_back(callname); } @@ -45,7 +46,7 @@ public: void exit(fsm1* f); }; - explicit fsm1(srslte::log_ref log_) : srslte::fsm_t(log_) {} + explicit fsm1(srslog::basic_logger& logger) : srslte::fsm_t(logger) {} // this state is another FSM class fsm2 : public subfsm_t @@ -55,22 +56,22 @@ public: struct state_inner { void enter(fsm2* f) { - call_log_helper(this, f->get_log(), "enter"); + call_log_helper(this, f->get_logger(), "enter"); f->parent_fsm()->inner_enter_counter++; } }; struct state_inner2 { - void enter(fsm2* f) { call_log_helper(this, f->get_log(), "enter"); } - void exit(fsm2* f) { call_log_helper(this, f->get_log(), "exit"); } + void enter(fsm2* f) { call_log_helper(this, f->get_logger(), "enter"); } + void exit(fsm2* f) { call_log_helper(this, f->get_logger(), "exit"); } }; explicit fsm2(fsm1* f_) : composite_fsm_t(f_) {} fsm2(fsm2&&) = default; fsm2& operator=(fsm2&&) = default; - ~fsm2() { get_log()->info("%s being destroyed!", get_type_name(*this).c_str()); } + ~fsm2() { get_logger().info("%s being destroyed!", get_type_name(*this).c_str()); } - void enter(fsm1* f) { call_log_helper(this, get_log(), "enter"); } - void exit(fsm1* f) { call_log_helper(this, get_log(), "exit"); } + void enter(fsm1* f) { call_log_helper(this, get_logger(), "enter"); } + void exit(fsm1* f) { call_log_helper(this, get_logger(), "exit"); } private: void inner_action1(state_inner& s, const ev1& e); @@ -117,54 +118,54 @@ protected: void fsm1::idle_st::enter(fsm1* f) { - call_log_helper(this, f->log_h, "enter"); + call_log_helper(this, f->logger, "enter"); f->idle_enter_counter++; } void fsm1::state1::enter(fsm1* f, const ev1& ev) { - call_log_helper(this, f->log_h, "enter"); + call_log_helper(this, f->logger, "enter"); f->state1_enter_counter++; } void fsm1::state1::enter(fsm1* f, const ev2& ev) { - call_log_helper(this, f->log_h, "enter2"); + call_log_helper(this, f->logger, "enter2"); f->state1_enter_counter++; } void fsm1::state1::exit(fsm1* f) { - call_log_helper(this, f->log_h, "exit"); + call_log_helper(this, f->logger, "exit"); } // FSM event handlers void fsm1::fsm2::inner_action1(state_inner& s, const ev1& e) { - call_log_helper(this, get_log(), "inner_action1"); + call_log_helper(this, get_logger(), "inner_action1"); } void fsm1::fsm2::inner_action2(state_inner& s, const ev2& e) { - call_log_helper(this, get_log(), "inner_action2"); + call_log_helper(this, get_logger(), "inner_action2"); } void fsm1::fsm2::inner_action3(state_inner2& s, const ev2& e) { - get_log()->info("fsm2::state_inner2::react called\n"); + get_logger().info("fsm2::state_inner2::react called"); } void fsm1::action1(idle_st& s, const ev1& e) { - call_log_helper(this, log_h, "action1"); + call_log_helper(this, logger, "action1"); foo(e); } void fsm1::action2(state1& s, const ev1& ev) { - call_log_helper(this, log_h, "action2"); + call_log_helper(this, logger, "action2"); } void fsm1::action3(state1& s, const ev2& ev) { - call_log_helper(this, log_h, "action3"); + call_log_helper(this, logger, "action3"); } // Static Checks @@ -172,17 +173,16 @@ void fsm1::action3(state1& s, const ev2& ev) namespace srslte { namespace fsm_details { -static_assert(is_fsm::value, "invalid metafunction\n"); -static_assert(is_composite_fsm::value, "invalid metafunction\n"); +static_assert(is_fsm::value, "invalid metafunction"); +static_assert(is_composite_fsm::value, "invalid metafunction"); static_assert(type_list_size(typename filter_transition_type >::type{}) > 0, - "invalid filter metafunction\n"); + "invalid filter metafunction"); static_assert( std::is_same, fsm1::state_list >::value, - "get state list failed\n"); -static_assert(fsm1::can_hold_state(), "failed can_hold_state check\n"); -static_assert(std::is_same, void>::value, "get state list failed\n"); -static_assert(std::is_same, void>::value, - "get state list failed\n"); + "get state list failed"); +static_assert(fsm1::can_hold_state(), "failed can_hold_state check"); +static_assert(std::is_same, void>::value, "get state list failed"); +static_assert(std::is_same, void>::value, "get state list failed"); } // namespace fsm_details } // namespace srslte @@ -191,10 +191,10 @@ static_assert(std::is_same, int test_hsm() { - srslte::log_ref log_h{"HSM"}; - log_h->set_level(srslte::LOG_LEVEL_INFO); + srslog::basic_logger& logger = srslog::fetch_basic_logger("HSM", false); + logger.set_level(srslog::basic_levels::info); - fsm1 f{log_h}; + fsm1 f{logger}; TESTASSERT(f.idle_enter_counter == 1); TESTASSERT(get_type_name(f) == "fsm1"); TESTASSERT(f.current_state_name() == "idle_st"); @@ -280,7 +280,7 @@ public: void enter(proc1* f, const srslte::proc_launch_ev& ev); }; - explicit proc1(srslte::log_ref log_) : base_t(log_) {} + explicit proc1(srslog::basic_logger& logger) : base_t(logger) {} protected: // Transitions @@ -307,18 +307,18 @@ protected: void proc1::procstate1::enter(proc1* f, const launch_ev& ev) { - f->log_h->info("started!\n"); + f->logger.info("started!"); } void proc1::handle_success(procstate1& s, const procevent1& ev) { - log_h->info("success!\n"); + logger.info("success!"); trigger(complete_ev{5}); } void proc1::handle_failure(procstate1& s, const procevent1& ev) { - log_h->info("failure!\n"); + logger.info("failure!"); trigger(complete_ev{3}); } @@ -328,9 +328,8 @@ public: struct st2 {}; using proc1_st = srslte::proc_wait_st; - explicit proc_listener_fsm(srslte::log_ref log_, proc1* proc_ptr_) : - base_t(log_), - states(this, st1{}, st2{}, proc1_st{proc_ptr_}) + proc_listener_fsm(srslog::basic_logger& logger, proc1* proc_ptr_) : + base_t(logger), states(this, st1{}, st2{}, proc1_st{proc_ptr_}) {} protected: @@ -352,9 +351,9 @@ protected: int test_fsm_proc() { - proc1 proc{srslte::logmap::get("PROC")}; - proc.get_log()->set_level(srslte::LOG_LEVEL_INFO); - proc.set_fsm_event_log_level(srslte::LOG_LEVEL_INFO); + proc1 proc{srslog::fetch_basic_logger("PROC", false)}; + proc.get_logger().set_level(srslog::basic_levels::info); + proc.set_fsm_event_log_level(srslog::basic_levels::info); int v = 2; TESTASSERT(proc.current_state_name() == "idle_st"); @@ -374,7 +373,7 @@ int test_fsm_proc() TESTASSERT(proc.get_result() == 3); { - proc_listener_fsm outer_fsm{srslte::logmap::get("TEST"), &proc}; + proc_listener_fsm outer_fsm{srslog::fetch_basic_logger("TEST"), &proc}; TESTASSERT(outer_fsm.is_in_state()); outer_fsm.trigger(6); TESTASSERT(outer_fsm.is_in_state()); @@ -385,7 +384,7 @@ int test_fsm_proc() } { - proc_listener_fsm outer_fsm{srslte::logmap::get("TEST"), &proc}; + proc_listener_fsm outer_fsm{srslog::fetch_basic_logger("TEST"), &proc}; TESTASSERT(outer_fsm.is_in_state()); proc.trigger(srslte::proc_launch_ev{v}); TESTASSERT(proc.is_running()); @@ -426,7 +425,7 @@ public: struct detach_request_ev {}; struct detach_accept_ev {}; - nas_fsm(srslte::log_ref log_) : fsm_t(log_) {} + explicit nas_fsm(srslog::basic_logger& logger) : fsm_t(logger) {} protected: state_listset_level(srslte::LOG_LEVEL_INFO); - nas_fsm fsm{log_h}; + auto& logger = srslog::fetch_basic_logger("NAS", false); + logger.set_level(srslog::basic_levels::info); + + nas_fsm fsm{logger}; + TESTASSERT(fsm.is_in_state()); // NULL -> EMM-DEREGISTERED @@ -539,7 +540,7 @@ struct fsm3 : public srslte::fsm_t { } }; - fsm3() : base_t(srslte::log_ref{"TEST"}) {} + fsm3() : base_t(srslog::fetch_basic_logger("TEST")) {} std::vector events; @@ -591,16 +592,18 @@ int test_fsm_self_trigger() int main() { - srslte::log_ref testlog{"TEST"}; - testlog->set_level(srslte::LOG_LEVEL_INFO); + srslog::basic_logger& logger = srslog::fetch_basic_logger("TEST", false); + logger.set_level(srslog::basic_levels::info); + srslog::init(); + TESTASSERT(test_hsm() == SRSLTE_SUCCESS); - testlog->info("TEST \"hsm\" finished successfully\n\n"); + logger.info("TEST \"hsm\" finished successfully\n"); TESTASSERT(test_fsm_proc() == SRSLTE_SUCCESS); - testlog->info("TEST \"proc\" finished successfully\n\n"); + logger.info("TEST \"proc\" finished successfully\n"); TESTASSERT(test_nas_fsm() == SRSLTE_SUCCESS); - testlog->info("TEST \"nas fsm\" finished successfully\n\n"); + logger.info("TEST \"nas fsm\" finished successfully\n"); TESTASSERT(test_fsm_self_trigger() == SRSLTE_SUCCESS); - testlog->info("TEST \"fsm self trigger\" finished successfully\n\n"); + logger.info("TEST \"fsm self trigger\" finished successfully\n"); return SRSLTE_SUCCESS; } diff --git a/srsenb/hdr/stack/rrc/rrc.h b/srsenb/hdr/stack/rrc/rrc.h index 517578b26..c8aa4102d 100644 --- a/srsenb/hdr/stack/rrc/rrc.h +++ b/srsenb/hdr/stack/rrc/rrc.h @@ -147,7 +147,6 @@ private: pdcp_interface_rrc* pdcp = nullptr; gtpu_interface_rrc* gtpu = nullptr; s1ap_interface_rrc* s1ap = nullptr; - srslte::log_ref rrc_log; srslog::basic_logger& logger; // derived params diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index d985835b9..2c529cb54 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -28,8 +28,7 @@ using namespace asn1::rrc; namespace srsenb { -rrc::rrc(srslte::task_sched_handle task_sched_) : - rrc_log("RRC"), logger(srslog::fetch_basic_logger("RRC")), task_sched(task_sched_) +rrc::rrc(srslte::task_sched_handle task_sched_) : logger(srslog::fetch_basic_logger("RRC")), task_sched(task_sched_) { pending_paging.clear(); ue_pool.reserve(16); @@ -865,7 +864,6 @@ void rrc::configure_mbsfn_sibs() int rrc::pack_mcch() { - mcch.msg.set_c1(); mbsfn_area_cfg_r9_s& area_cfg_r9 = mcch.msg.c1().mbsfn_area_cfg_r9(); area_cfg_r9.common_sf_alloc_period_r9 = mbsfn_area_cfg_r9_s::common_sf_alloc_period_r9_e_::rf64; diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index 17f610919..ef0e582ea 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -183,7 +183,7 @@ uint16_t rrc::start_ho_ue_resource_alloc(const asn1::s1ap::ho_request_s& ************************************************************************************************/ rrc::ue::rrc_mobility::rrc_mobility(rrc::ue* outer_ue) : - base_t(outer_ue->parent->rrc_log), + base_t(outer_ue->parent->logger), rrc_ue(outer_ue), rrc_enb(outer_ue->parent), pool(outer_ue->pool), @@ -385,7 +385,7 @@ void rrc::ue::rrc_mobility::handle_ho_preparation_complete(bool srslte::unique_byte_buffer_t container) { if (not is_success) { - log_h->info("Received S1AP HandoverFailure. Aborting Handover..."); + logger.info("Received S1AP HandoverFailure. Aborting Handover..."); trigger(srslte::failure_ev{}); return; } @@ -394,15 +394,15 @@ void rrc::ue::rrc_mobility::handle_ho_preparation_complete(bool { asn1::cbit_ref bref(container->msg, container->N_bytes); if (rrchocmd.unpack(bref) != asn1::SRSASN_SUCCESS) { - get_log()->warning("Unpacking of RRC HOCommand was unsuccessful"); - get_log()->warning_hex(container->msg, container->N_bytes, "Received container:"); + get_logger().warning("Unpacking of RRC HOCommand was unsuccessful"); + get_logger().warning(container->msg, container->N_bytes, "Received container:"); trigger(ho_cancel_ev{}); return; } } if (rrchocmd.crit_exts.type().value != c1_or_crit_ext_opts::c1 or rrchocmd.crit_exts.c1().type().value != ho_cmd_s::crit_exts_c_::c1_c_::types_opts::ho_cmd_r8) { - get_log()->warning("Only handling r8 Handover Commands"); + get_logger().warning("Only handling r8 Handover Commands"); trigger(ho_cancel_ev{}); return; } @@ -573,7 +573,7 @@ bool rrc::ue::rrc_mobility::s1_source_ho_st::start_enb_status_transfer(const asn void rrc::ue::rrc_mobility::s1_source_ho_st::wait_ho_cmd::enter(s1_source_ho_st* f, const ho_meas_report_ev& ev) { srslte::console("Starting S1 Handover of rnti=0x%x to cellid=0x%x.\n", f->rrc_ue->rnti, ev.target_eci); - f->get_log()->info("Starting S1 Handover of rnti=0x%x to cellid=0x%x.", f->rrc_ue->rnti, ev.target_eci); + f->get_logger().info("Starting S1 Handover of rnti=0x%x to cellid=0x%x.", f->rrc_ue->rnti, ev.target_eci); f->report = ev; bool success = f->parent_fsm()->start_ho_preparation(f->report.target_eci, f->report.meas_obj->meas_obj_id, false); @@ -781,10 +781,10 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho for (const auto& erab_item : ho_req_msg.protocol_ies.erab_to_be_setup_list_ho_req.value) { auto& erab = erab_item.value.erab_to_be_setup_item_ho_req(); if (erab.ext) { - get_log()->warning("Not handling E-RABToBeSetupList extensions"); + get_logger().warning("Not handling E-RABToBeSetupList extensions"); } if (erab.transport_layer_address.length() > 32) { - get_log()->error("IPv6 addresses not currently supported"); + get_logger().error("IPv6 addresses not currently supported"); trigger(srslte::failure_ev{}); return false; } @@ -792,7 +792,7 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho if (not erab.ie_exts_present or not erab.ie_exts.data_forwarding_not_possible_present or erab.ie_exts.data_forwarding_not_possible.ext.value != asn1::s1ap::data_forwarding_not_possible_opts::data_forwarding_not_possible) { - get_log()->warning("Data Forwarding of E-RABs not supported"); + get_logger().warning("Data Forwarding of E-RABs not supported"); } // Create E-RAB and associated main GTPU tunnel @@ -910,12 +910,12 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f, const ho_meas target_cell = f->rrc_enb->cell_common_list->get_cell_id(cell_id); source_cell = f->rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common; if (target_cell == nullptr) { - f->log_h->error("The target cell_id=0x%x was not found in the list of eNB cells", cell_id); + f->logger.error("The target cell_id=0x%x was not found in the list of eNB cells", cell_id); f->trigger(srslte::failure_ev{}); return; } - f->log_h->info("Starting intraeNB Handover of rnti=0x%x to 0x%x.", f->rrc_ue->rnti, meas_report.target_eci); + f->logger.info("Starting intraeNB Handover of rnti=0x%x to 0x%x.", f->rrc_ue->rnti, meas_report.target_eci); if (target_cell == nullptr) { f->trigger(srslte::failure_ev{}); diff --git a/srsenb/test/upper/rrc_mobility_test.cc b/srsenb/test/upper/rrc_mobility_test.cc index 6aebff24e..c945d08b6 100644 --- a/srsenb/test/upper/rrc_mobility_test.cc +++ b/srsenb/test/upper/rrc_mobility_test.cc @@ -516,6 +516,8 @@ int main(int argc, char** argv) logger.set_level(srslog::basic_levels::info); logger.set_hex_dump_max_size(1024); + srslog::init(); + using event = mobility_test_params::test_event; if (argc < 3) { diff --git a/srsue/src/stack/rrc/phy_controller.cc b/srsue/src/stack/rrc/phy_controller.cc index 89ff2b6cb..c0d6e48d8 100644 --- a/srsue/src/stack/rrc/phy_controller.cc +++ b/srsue/src/stack/rrc/phy_controller.cc @@ -24,7 +24,7 @@ std::string to_string(const phy_cell_t& cell) phy_controller::phy_controller(srsue::phy_interface_rrc_lte* phy_, srslte::task_sched_handle task_sched_, std::function on_cell_selection) : - base_t(srslte::log_ref{"RRC"}), + base_t(srslog::fetch_basic_logger("RRC")), phy(phy_), task_sched(task_sched_), cell_selection_always_observer(std::move(on_cell_selection)) @@ -37,13 +37,13 @@ void phy_controller::in_sync() bool phy_controller::set_cell_config(const srslte::phy_cfg_t& config, uint32_t cc_idx) { - log_h->info("Setting PHY config for cc_idx=%d", cc_idx); + logger.info("Setting PHY config for cc_idx=%d", cc_idx); return set_cell_config(config, cc_idx, true); } void phy_controller::set_phy_to_default() { - log_h->info("Setting default PHY config (common and dedicated)"); + logger.info("Setting default PHY config (common and dedicated)"); srslte::phy_cfg_t& default_cfg = current_cells_cfg[0]; default_cfg.set_defaults(); @@ -55,7 +55,7 @@ void phy_controller::set_phy_to_default() /// Apply default PHY config for all SCells as specified in TS 36.331 9.2.4 void phy_controller::set_phy_to_default_dedicated() { - log_h->info("Setting default dedicated PHY config"); + logger.info("Setting default dedicated PHY config"); srslte::phy_cfg_t& default_cfg = current_cells_cfg[0]; default_cfg.set_defaults_dedicated(); @@ -66,7 +66,7 @@ void phy_controller::set_phy_to_default_dedicated() void phy_controller::set_phy_to_default_pucch_srs() { - log_h->info("Setting default PHY config dedicated"); + logger.info("Setting default PHY config dedicated"); srslte::phy_cfg_t& default_cfg_ded = current_cells_cfg[0]; default_cfg_ded.set_defaults_pucch_sr(); @@ -91,7 +91,7 @@ bool phy_controller::set_cell_config(const srslte::phy_cfg_t& cfg, uint32_t cc_i void phy_controller::set_config_complete() { if (nof_pending_configs == 0) { - log_h->warning("Received more phy config complete signals than the ones scheduled"); + logger.warning("Received more phy config complete signals than the ones scheduled"); return; } nof_pending_configs--; @@ -104,12 +104,12 @@ void phy_controller::set_config_complete() bool phy_controller::start_cell_select(const phy_cell_t& phy_cell, srslte::event_observer observer) { if (is_in_state()) { - log_h->warning("Failed to launch cell selection as it is already running"); + logger.warning("Failed to launch cell selection as it is already running"); return false; } trigger(cell_sel_cmd{phy_cell}); if (not is_in_state()) { - log_h->warning("Failed to launch cell selection. Current state: %s", current_state_name().c_str()); + logger.warning("Failed to launch cell selection. Current state: %s", current_state_name().c_str()); return false; } cell_selection_notifier = std::move(observer); diff --git a/srsue/test/upper/rrc_phy_ctrl_test.cc b/srsue/test/upper/rrc_phy_ctrl_test.cc index 0c8760372..406ed65a3 100644 --- a/srsue/test/upper/rrc_phy_ctrl_test.cc +++ b/srsue/test/upper/rrc_phy_ctrl_test.cc @@ -16,8 +16,6 @@ namespace srsue { -srslte::log_ref test_log{"TEST"}; - struct cell_search_result_test { cell_search_result_test(phy_controller* phy_ctrl_) : phy_ctrl(phy_ctrl_) {} @@ -27,8 +25,8 @@ struct cell_search_result_test { result = result_; if (phy_ctrl->current_state_name() == "searching_cell" or phy_ctrl->is_trigger_locked()) { - phy_ctrl->get_log()->error( - "When caller is signalled with cell search result, cell search state cannot be active\n"); + phy_ctrl->get_logger().error( + "When caller is signalled with cell search result, cell search state cannot be active"); exit(1); } } @@ -45,16 +43,16 @@ struct cell_select_result_test { { result = result_ ? 1 : 0; if (phy_ctrl->current_state_name() == "selecting_cell" or phy_ctrl->is_trigger_locked()) { - phy_ctrl->get_log()->error( - "When caller is signalled with cell select result, cell select state cannot be active\n"); + phy_ctrl->get_logger().error( + "When caller is signalled with cell select result, cell select state cannot be active"); exit(1); } // start a new cell selection right away if (counter++ < 1) { phy_cell_t new_cell = {}; - new_cell.pci = 3; - new_cell.earfcn = 3400; + new_cell.pci = 3; + new_cell.earfcn = 3400; phy_ctrl->start_cell_select(new_cell, *this); } } @@ -193,9 +191,15 @@ int test_phy_cell_select_init_error_handling() int main() { - srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_INFO); + auto& test_logger = srslog::fetch_basic_logger("TEST", false); + test_logger.set_level(srslog::basic_levels::info); + test_logger.set_hex_dump_max_size(-1); + auto& RRC_logger = srslog::fetch_basic_logger("RRC", false); + RRC_logger.set_level(srslog::basic_levels::info); + RRC_logger.set_hex_dump_max_size(-1); + srslog::init(); TESTASSERT(srsue::test_phy_ctrl_fsm() == SRSLTE_SUCCESS); TESTASSERT(srsue::test_phy_cell_select_init_error_handling() == SRSLTE_SUCCESS); - srsue::test_log->info("Finished RRC PHY controller test successfully\n"); + test_logger.info("Finished RRC PHY controller test successfully"); }