Replaced loggers in buffer_pool.h

master
faluco 4 years ago committed by faluco
parent f8485fb799
commit d37a07a47f

@ -26,6 +26,7 @@
#include "srslte/common/common.h"
#include "srslte/common/log.h"
#include "srslte/srslog/srslog.h"
namespace srslte {
@ -164,8 +165,8 @@ class byte_buffer_pool
public:
// Singleton static methods
static std::unique_ptr<byte_buffer_pool> instance;
static byte_buffer_pool* get_instance(int capacity = -1);
static void cleanup();
static byte_buffer_pool* get_instance(int capacity = -1);
static void cleanup();
byte_buffer_pool(int capacity = -1)
{
log = nullptr;
@ -178,7 +179,7 @@ public:
{
return pool->allocate(debug_name, blocking);
}
void set_log(srslte::log* log) { this->log = log; }
void enable_logger(bool enabled) { print_to_log = enabled; }
void deallocate(byte_buffer_t* b)
{
if (!b) {
@ -186,26 +187,30 @@ public:
}
b->clear();
if (!pool->deallocate(b)) {
if (log) {
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
log->error("Deallocating PDU: Addr=0x%p, name=%s not found in pool\n", b, b->debug_name);
print_error("Error deallocating PDU: Addr=0x%p, name=%s not found in pool", (void*)b, b->debug_name);
#else
log->error("Deallocating PDU: Addr=0x%p\n", b);
print_error("Error deallocating PDU: Addr=0x%p", (void*)b);
#endif
} else {
#ifdef SRSLTE_BUFFER_POOL_LOG_ENABLED
printf("Error deallocating PDU: Addr=0x%p, name=%s not found in pool\n", b, b->debug_name);
#else
printf("Error deallocating PDU: Addr=0x%p\n", b);
#endif
}
}
b = nullptr;
}
void print_all_buffers() { pool->print_all_buffers(); }
private:
srslte::log* log;
/// Formats and prints the input string and arguments into the configured output stream.
template <typename... Args>
void print_error(const char* str, Args&&... args)
{
if (print_to_log) {
srslog::fetch_basic_logger("POOL", false).error(str, std::forward<Args>(args)...);
} else {
fmt::printf(std::string(str) + "\n", std::forward<Args>(args)...);
}
}
private:
bool print_to_log = false;
buffer_pool<byte_buffer_t>* pool;
};

@ -139,8 +139,6 @@ private:
srslog::sink& log_sink;
srslog::basic_logger& enb_log;
srslte::log_filter pool_log;
srslte::byte_buffer_pool* pool = nullptr;
all_args_t args = {};

@ -30,7 +30,6 @@ enb::enb(srslog::sink& log_sink) :
enb_log(srslog::fetch_basic_logger("ENB", log_sink, false)),
pool(srslte::byte_buffer_pool::get_instance(ENB_POOL_SIZE))
{
// print build info
std::cout << std::endl << get_build_string() << std::endl << std::endl;
}
@ -56,9 +55,7 @@ int enb::init(const all_args_t& args_, srslte::logger* logger_)
return SRSLTE_ERROR;
}
pool_log.init("POOL", logger);
pool_log.set_level(srslte::LOG_LEVEL_ERROR);
pool->set_log(&pool_log);
pool->enable_logger(true);
// Create layers
if (args.stack.type == "lte") {

@ -161,7 +161,6 @@ private:
srslte::log_ref rrc_log{"RRC"};
srslte::log_ref usim_log{"USIM"};
srslte::log_ref nas_log{"NAS"};
srslte::log_ref pool_log{"POOL"};
srslog::basic_logger& stack_logger;
srslog::basic_logger& mac_logger;
srslog::basic_logger& rlc_logger;
@ -184,12 +183,12 @@ private:
srslte::tprof<srslte::sliding_window_stats_ms> 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 mac;
srslte::mac_pcap mac_pcap;
srslte::nas_pcap nas_pcap;
srslte::rlc rlc;
srslte::pdcp pdcp;
srsue::rrc rrc;
#ifdef HAVE_5GNR
srsue::mac_nr mac_nr;
srsue::rrc_nr rrc_nr;

@ -62,9 +62,9 @@ public:
void stop();
// GW srsue stack_interface_gw dummy interface
bool is_registered(){return true;};
bool start_service_request(){return true;};
bool is_registered() { return true; };
bool start_service_request() { return true; };
bool get_metrics(stack_metrics_t* metrics);
bool is_rrc_connected();
@ -105,7 +105,6 @@ private:
srslte::logger* logger = nullptr;
srslte::log_ref rlc_log;
srslte::log_ref pdcp_log;
srslte::log_ref pool_log;
// stack components
std::unique_ptr<mac_nr> mac;

@ -87,8 +87,7 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_)
// init own log
stack_logger.set_level(srslog::str_to_basic_level(args.log.stack_level));
stack_logger.set_hex_dump_max_size(args.log.stack_hex_limit);
pool_log->set_level(srslte::LOG_LEVEL_WARNING);
byte_buffer_pool::get_instance()->set_log(pool_log.get());
byte_buffer_pool::get_instance()->enable_logger(true);
// init layer logs
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new srslte::log_filter{"MAC", logger, true}});

@ -18,7 +18,7 @@ using namespace srslte;
namespace srsue {
ue_stack_nr::ue_stack_nr(srslte::logger* logger_) :
logger(logger_), thread("STACK"), task_sched(64, 2, 64), rlc_log("RLC"), pdcp_log("PDCP"), pool_log("POOL")
logger(logger_), thread("STACK"), task_sched(64, 2, 64), rlc_log("RLC"), pdcp_log("PDCP")
{
mac.reset(new mac_nr(&task_sched));
pdcp.reset(new srslte::pdcp(&task_sched, "PDCP"));
@ -26,8 +26,7 @@ ue_stack_nr::ue_stack_nr(srslte::logger* logger_) :
rrc.reset(new rrc_nr(&task_sched));
// setup logging for pool, RLC and PDCP
pool_log->set_level(srslte::LOG_LEVEL_ERROR);
byte_buffer_pool::get_instance()->set_log(pool_log.get());
byte_buffer_pool::get_instance()->enable_logger(true);
ue_task_queue = task_sched.make_task_queue();
sync_task_queue = task_sched.make_task_queue();

Loading…
Cancel
Save