diff --git a/srsenb/enb.conf.example b/srsenb/enb.conf.example index 6847f7392..5e386ddc1 100644 --- a/srsenb/enb.conf.example +++ b/srsenb/enb.conf.example @@ -98,8 +98,9 @@ filename = /tmp/enb.pcap # Logging layers: phy, mac, rlc, pdcp, rrc, nas, gtpu, usim, all # Logging levels: debug, info, warning, error, none # -# filename: File path to use for log output -##################################################################### +# filename: File path to use for log output. Can be set to stdout +# to print logs to standard output +git c##################################################################### [log] all_level = info all_hex_limit = 32 diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index 8b847302e..7b1681cd6 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -138,8 +138,6 @@ typedef struct { Main UE class *******************************************************************************/ -//#define LOG_STDOUT - class enb :public enb_metrics_interface { public: @@ -180,11 +178,10 @@ private: srsenb::gtpu gtpu; srsenb::s1ap s1ap; -#ifdef LOG_STDOUT - srslte::logger_stdout logger; -#else - srslte::logger_file logger; -#endif + srslte::logger_stdout logger_stdout; + srslte::logger_file logger_file; + srslte::logger *logger; + srslte::log_filter rf_log; std::vector phy_log; srslte::log_filter mac_log; diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index e2c1c9a29..d00fd4c0b 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -26,6 +26,7 @@ #include #include +#include #include "enb.h" namespace srsenb { @@ -68,30 +69,34 @@ bool enb::init(all_args_t *args_) { args = args_; -#ifndef LOG_STDOUT - logger.init(args->log.filename); -#endif - rf_log.init("RF ", &logger); + if (!args->log.filename.compare("stdout")) { + logger = &logger_stdout; + printf("log name is output\n"); + } else { + printf("lgo name is %s\n", args->log.filename.c_str()); + logger_file.init(args->log.filename); + logger_file.log("\n\n"); + logger = &logger_file; + } + + rf_log.init("RF ", logger); // Create array of pointers to phy_logs for (int i=0;iexpert.phy.nof_phy_threads;i++) { srslte::log_filter *mylog = new srslte::log_filter; char tmp[16]; sprintf(tmp, "PHY%d",i); - mylog->init(tmp, &logger, true); + mylog->init(tmp, logger, true); phy_log.push_back((void*) mylog); } - mac_log.init("MAC ", &logger, true); - rlc_log.init("RLC ", &logger); - pdcp_log.init("PDCP", &logger); - rrc_log.init("RRC ", &logger); - gtpu_log.init("GTPU", &logger); - s1ap_log.init("S1AP", &logger); + mac_log.init("MAC ", logger, true); + rlc_log.init("RLC ", logger); + pdcp_log.init("PDCP", logger); + rrc_log.init("RRC ", logger); + gtpu_log.init("GTPU", logger); + s1ap_log.init("S1AP", logger); // Init logs -#ifndef LOG_STDOUT - logger.log("\n\n"); -#endif rf_log.set_level(srslte::LOG_LEVEL_INFO); for (int i=0;iexpert.phy.nof_phy_threads;i++) { ((srslte::log_filter*) phy_log[i])->set_level(level(args->log.phy_level)); diff --git a/srsue/hdr/ue.h b/srsue/hdr/ue.h index 57dce1231..4e48f6b6d 100644 --- a/srsue/hdr/ue.h +++ b/srsue/hdr/ue.h @@ -57,8 +57,6 @@ namespace srsue { -//#define LOG_STDOUT - /******************************************************************************* Main UE class *******************************************************************************/ @@ -97,11 +95,10 @@ private: srsue::gw gw; srsue::usim usim; -#ifdef LOG_STDOUT - srslte::logger_stdout logger; -#else - srslte::logger_file logger; -#endif + srslte::logger_stdout logger_stdout; + srslte::logger_file logger_file; + srslte::logger *logger; + // rf_log is on ue_base std::vector phy_log; srslte::log_filter mac_log; diff --git a/srsue/src/main.cc b/srsue/src/main.cc index f095a60c4..02394f3e4 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -103,6 +103,7 @@ void parse_args(all_args_t *args, int argc, char *argv[]) { ("log.usim_level", bpo::value(&args->log.usim_level), "USIM log level") ("log.usim_hex_limit", bpo::value(&args->log.usim_hex_limit), "USIM log hex dump limit") + ("log.all_level", bpo::value(&args->log.all_level)->default_value("info"), "ALL log level") ("log.all_hex_limit", bpo::value(&args->log.all_hex_limit)->default_value(32), "ALL log hex dump limit") diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index aab6bbc08..646b87612 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -32,6 +32,7 @@ #include #include #include +#include using namespace srslte; @@ -52,31 +53,33 @@ bool ue::init(all_args_t *args_) { args = args_; -#ifndef LOG_STDOUT - logger.init(args->log.filename); -#endif - rf_log.init("RF ", &logger); + if (!args->log.filename.compare("stdout")) { + logger = &logger_stdout; + } else { + logger_file.init(args->log.filename); + logger_file.log("\n\n"); + logger = &logger_file; + } + + rf_log.init("RF ", logger); // Create array of pointers to phy_logs for (int i=0;iexpert.phy.nof_phy_threads;i++) { srslte::log_filter *mylog = new srslte::log_filter; char tmp[16]; sprintf(tmp, "PHY%d",i); - mylog->init(tmp, &logger, true); + mylog->init(tmp, logger, true); phy_log.push_back((void*) mylog); } - mac_log.init("MAC ", &logger, true); - rlc_log.init("RLC ", &logger); - pdcp_log.init("PDCP", &logger); - rrc_log.init("RRC ", &logger); - nas_log.init("NAS ", &logger); - gw_log.init("GW ", &logger); - usim_log.init("USIM", &logger); + mac_log.init("MAC ", logger, true); + rlc_log.init("RLC ", logger); + pdcp_log.init("PDCP", logger); + rrc_log.init("RRC ", logger); + nas_log.init("NAS ", logger); + gw_log.init("GW ", logger); + usim_log.init("USIM", logger); // Init logs -#ifndef LOG_STDOUT - logger.log("\n\n"); -#endif rf_log.set_level(srslte::LOG_LEVEL_INFO); for (int i=0;iexpert.phy.nof_phy_threads;i++) { ((srslte::log_filter*) phy_log[i])->set_level(level(args->log.phy_level)); diff --git a/srsue/ue.conf.example b/srsue/ue.conf.example index 76868008f..30b152280 100644 --- a/srsue/ue.conf.example +++ b/srsue/ue.conf.example @@ -64,7 +64,8 @@ filename = /tmp/ue.pcap # Logging layers: phy, mac, rlc, pdcp, rrc, nas, gw, usim, all # Logging levels: debug, info, warning, error, none # -# filename: File path to use for log output +# filename: File path to use for log output. Can be set to stdout +# to print logs to standard output ##################################################################### [log] all_level = info