Import of srslog into srsepc and srsenb. (#1574)

* - Import of srslog into srsepc and srsenb.
* - Removed logger_file and logger_stdout files.
master
faluco 4 years ago committed by GitHub
parent 21e9a3958f
commit cfd3f51931
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -35,7 +35,7 @@
#include "srslte/common/log.h"
#include "srslte/common/logger.h"
#include "srslte/common/logger_stdout.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/phy/common/timestamp.h"
namespace srslte {
@ -75,6 +75,7 @@ public:
void set_time_src(time_itf* source, time_format_t format);
protected:
std::unique_ptr<logger> default_logger;
logger* logger_h;
bool do_tti;
@ -83,8 +84,6 @@ protected:
time_itf* time_src;
time_format_t time_format;
logger_stdout def_logger_stdout;
void all_log(srslte::LOG_LEVEL_ENUM level,
uint32_t tti,
const char* msg,

@ -1,72 +0,0 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
/******************************************************************************
* File: logger_file.h
* Description: Common log object. Maintains a queue of log messages
* and runs a thread to read messages and write to file.
* Multiple producers, single consumer. If full, producers
* increase queue size. If empty, consumer blocks.
*****************************************************************************/
#ifndef SRSLTE_LOGGER_FILE_H
#define SRSLTE_LOGGER_FILE_H
#include "srslte/common/logger.h"
#include "srslte/common/threads.h"
#include <deque>
#include <stdio.h>
#include <string>
namespace srslte {
typedef std::string* str_ptr;
class logger_file : public thread, public logger
{
public:
logger_file();
logger_file(std::string file);
~logger_file();
void init(std::string file, int max_length = -1);
void stop();
// Implementation of log_out
void log(unique_log_str_t msg);
private:
void run_thread();
void flush();
uint32_t name_idx;
int64_t max_length;
int64_t cur_length;
FILE* logfile;
bool is_running;
std::string filename;
pthread_cond_t not_empty;
pthread_mutex_t mutex;
std::deque<unique_log_str_t> buffer;
};
} // namespace srslte
#endif // SRSLTE_LOGGER_FILE_H

@ -1,44 +0,0 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
/******************************************************************************
* File: logger_stdout.h
* Description: Interface for logging output
*****************************************************************************/
#ifndef SRSLTE_LOGGER_STDOUT_H
#define SRSLTE_LOGGER_STDOUT_H
#include "srslte/common/logger.h"
#include <stdio.h>
#include <string>
namespace srslte {
class logger_stdout : public logger
{
public:
void log(unique_log_str_t log_str) { fprintf(stdout, "%s", log_str->str()); }
};
} // namespace srslte
#endif // SRSLTE_LOGGER_STDOUT_H

@ -24,8 +24,10 @@
#include "srslte/common/log.h"
#include "srslte/common/logger.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/common/singleton.h"
#include <memory>
#include <mutex>
#include <unordered_map>
@ -85,10 +87,8 @@ protected:
private:
log_ref get_impl(std::string servicename);
// consts
std::unique_ptr<logger> logger_stdout_val;
// default cfg
std::unique_ptr<srslog_wrapper> stdout_channel;
logger* default_logger = nullptr;
srslte::LOG_LEVEL_ENUM default_log_level = LOG_LEVEL_WARNING;
int default_hex_limit = 1024;

@ -27,7 +27,6 @@
#ifndef SRSLTE_SIGNAL_HANDLER_H
#define SRSLTE_SIGNAL_HANDLER_H
#include "srslte/common/logger_file.h"
#include "srslte/srslog/sink.h"
#include <signal.h>
#include <stdio.h>
@ -40,7 +39,6 @@ extern "C" {
// static vars required by signal handling
static srslog::sink* log_sink = nullptr;
static srslte::logger_file logger_file;
static bool running = true;
static void srslte_signal_handler(int signal)
@ -49,7 +47,6 @@ static void srslte_signal_handler(int signal)
case SIGALRM:
fprintf(stderr, "Couldn't stop after %ds. Forcing exit.\n", SRSLTE_TERM_TIMEOUT_S);
//:TODO: refactor the sighandler, should not depend on log utilities
logger_file.stop();
if (log_sink) {
log_sink->flush();
}

@ -27,7 +27,6 @@ set(SOURCES arch_select.cc
liblte_security.cc
log_filter.cc
logmap.cc
logger_file.cc
logger_srslog_wrapper.cc
mac_pcap.cc
nas_pcap.cc
@ -58,6 +57,6 @@ add_dependencies(srslte_common gen_build_info)
add_executable(arch_select arch_select.cc)
target_include_directories(srslte_common PUBLIC ${SEC_INCLUDE_DIRS})
target_link_libraries(srslte_common srslte_phy ${SEC_LIBRARIES})
target_link_libraries(srslte_common srslte_phy srslog ${SEC_LIBRARIES})
add_subdirectory(test)

@ -28,6 +28,7 @@
#include <sys/time.h>
#include "srslte/common/log_filter.h"
#include "srslte/srslog/srslog.h"
namespace srslte {
@ -42,12 +43,30 @@ log_filter::log_filter() : log()
logger_h = NULL;
}
/// Creates a log channel that writes to stdout.
static srslog::log_channel* create_or_get_default_logger()
{
srslog::sink* s = srslog::create_stdout_sink();
if (!s) {
s = srslog::find_sink("stdout");
}
srslog::log_channel* log = srslog::create_log_channel("log_filter_default", *s);
if (!log) {
log = srslog::find_log_channel("log_filter_default");
}
srslog::init();
return log;
}
log_filter::log_filter(std::string layer) : log()
{
do_tti = false;
time_src = NULL;
time_format = TIME;
init(layer, &def_logger_stdout, do_tti);
default_logger = std::unique_ptr<srslog_wrapper>(new srslog_wrapper(*create_or_get_default_logger()));
init(layer, default_logger.get(), do_tti);
}
log_filter::log_filter(std::string layer, logger* logger_, bool tti) : log()
@ -57,7 +76,8 @@ log_filter::log_filter(std::string layer, logger* logger_, bool tti) : log()
time_format = TIME;
if (!logger_) {
logger_ = &def_logger_stdout;
default_logger = std::unique_ptr<srslog_wrapper>(new srslog_wrapper(*create_or_get_default_logger()));
logger_ = default_logger.get();
}
init(std::move(layer), logger_, tti);

@ -1,143 +0,0 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#define LOG_BUFFER_SIZE 1024 * 32
#include "srslte/common/logger_file.h"
using namespace std;
namespace srslte {
logger_file::logger_file() : logfile(NULL), is_running(false), cur_length(0), max_length(0), thread("LOGGER_FILE")
{
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&not_empty, NULL);
}
logger_file::~logger_file()
{
stop();
pthread_mutex_destroy(&mutex);
pthread_cond_destroy(&not_empty);
}
void logger_file::init(std::string file, int max_length_)
{
if (is_running) {
fprintf(stderr, "Error: logger thread is already running.\n");
return;
}
pthread_mutex_lock(&mutex);
max_length = (int64_t)max_length_ * 1024;
name_idx = 0;
filename = file;
logfile = fopen(filename.c_str(), "w");
if (logfile == NULL) {
printf("Error: could not create log file, no messages will be logged!\n");
}
is_running = true;
start(-2);
pthread_mutex_unlock(&mutex);
}
void logger_file::stop()
{
if (is_running) {
logger::log_char("Closing log\n");
pthread_mutex_lock(&mutex);
is_running = false;
pthread_cond_signal(&not_empty); // wakeup thread and let it terminate
pthread_mutex_unlock(&mutex);
wait_thread_finish();
pthread_mutex_lock(&mutex);
flush();
if (logfile) {
fclose(logfile);
logfile = NULL;
}
pthread_mutex_unlock(&mutex);
} else {
pthread_mutex_lock(&mutex);
flush(); // flush even if thread isn't running anymore
pthread_mutex_unlock(&mutex);
}
}
void logger_file::log(unique_log_str_t msg)
{
pthread_mutex_lock(&mutex);
buffer.push_back(std::move(msg));
pthread_cond_signal(&not_empty);
pthread_mutex_unlock(&mutex);
}
void logger_file::run_thread()
{
while (is_running) {
pthread_mutex_lock(&mutex);
while (buffer.empty()) {
pthread_cond_wait(&not_empty, &mutex);
if (!is_running) {
pthread_mutex_unlock(&mutex);
return; // Thread done. Messages in buffer will be handled in flush.
}
}
unique_log_str_t s = std::move(buffer.front());
int n = 0;
if (logfile) {
n = fprintf(logfile, "%s", s->str());
}
buffer.pop_front();
if (n > 0) {
cur_length += (int64_t)n;
if (cur_length >= max_length && max_length > 0) {
fclose(logfile);
name_idx++;
char numstr[21]; // enough to hold all numbers up to 64-bits
sprintf(numstr, ".%d", name_idx);
string newfilename = filename + numstr;
logfile = fopen(newfilename.c_str(), "w");
if (logfile == NULL) {
printf("Error: could not create log file, no messages will be logged!\n");
}
cur_length = 0;
}
}
pthread_mutex_unlock(&mutex);
}
}
void logger_file::flush()
{
std::deque<unique_log_str_t>::iterator it;
for (it = buffer.begin(); it != buffer.end(); it++) {
unique_log_str_t s = std::move(*it);
if (logfile) {
fprintf(logfile, "%s", s->str());
}
}
buffer.clear();
}
} // namespace srslte

@ -21,7 +21,7 @@
#include "srslte/common/logmap.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_stdout.h"
#include "srslte/srslog/srslog.h"
using namespace srslte;
@ -30,9 +30,27 @@ log_ref::log_ref(const char* name)
ptr_ = srslte::logmap::get(name).ptr_;
}
logmap::logmap() : logger_stdout_val(new logger_stdout{})
/// Creates a log channel that writes to stdout.
static srslog::log_channel* create_or_get_default_logger()
{
default_logger = logger_stdout_val.get();
srslog::sink* s = srslog::create_stdout_sink();
if (!s) {
s = srslog::find_sink("stdout");
}
srslog::log_channel* log = srslog::create_log_channel("logmap_default", *s);
if (!log) {
log = srslog::find_log_channel("logmap_default");
}
srslog::init();
return log;
}
logmap::logmap()
{
stdout_channel = std::unique_ptr<srslog_wrapper>(new srslog_wrapper(*create_or_get_default_logger()));
default_logger = stdout_channel.get();
}
// Access to log map by servicename. If servicename does not exist, create a new log_filter with default cfg

@ -19,9 +19,11 @@
*
*/
#include <srslte/common/log_filter.h>
#include <srslte/common/logger_srslog_wrapper.h>
#include <srslte/common/thread_pool.h>
#include <srslte/common/tti_sempahore.h>
#include <srslte/phy/utils/random.h>
#include <srslte/srslog/srslog.h>
class dummy_radio
{
@ -128,8 +130,21 @@ int main(int argc, char** argv)
std::vector<std::unique_ptr<dummy_worker> > workers;
srslte::tti_semaphore<uint32_t> tti_semaphore;
// Setup logging.
srslog::sink* s = srslog::create_stdout_sink();
if (!s) {
return SRSLTE_ERROR;
}
srslog::log_channel* chan = srslog::create_log_channel("main_channel", *s);
if (!chan) {
return SRSLTE_ERROR;
}
srslte::srslog_wrapper logger(*chan);
// Start the log backend.
srslog::init();
// Loggers
srslte::logger_stdout logger;
srslte::log_filter radio_log("radio", &logger);
std::vector<std::unique_ptr<srslte::log_filter> > worker_logs;

@ -23,10 +23,6 @@ find_package(SCTP REQUIRED)
#######################################################################
# COMMON TESTS
#######################################################################
add_executable(logger_file_test logger_file_test.cc)
target_link_libraries(logger_file_test srslte_phy srslte_common srslte_phy ${SEC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
add_test(logger_file_test logger_file_test)
add_executable(byte_buffer_queue_test byte_buffer_queue_test.cc)
target_link_libraries(byte_buffer_queue_test srslte_phy srslte_common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
add_test(byte_buffer_queue_test byte_buffer_queue_test)

@ -23,15 +23,16 @@
#define NMSGS 100
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_file.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/common/logmap.h"
#include "srslte/common/test_common.h"
#include "srslte/srslog/srslog.h"
#include <stdio.h>
using namespace srslte;
typedef struct {
logger_file* l;
logger* l;
int thread_id;
} args_t;
@ -78,8 +79,10 @@ void* thread_loop_hex(void* a)
void write(std::string filename)
{
logger_file l;
l.init(filename);
srslog::sink* s = srslog::create_file_sink(filename);
srslog::log_channel* chan = srslog::create_log_channel("write", *s);
srslte::srslog_wrapper l(*chan);
pthread_t threads[NTHREADS];
args_t args[NTHREADS];
for (int i = 0; i < NTHREADS; i++) {
@ -121,7 +124,15 @@ bool read(std::string filename)
int basic_hex_test()
{
logger_stdout l;
srslog::sink* s = srslog::find_sink("stdout");
if (!s) {
return SRSLTE_ERROR;
}
srslog::log_channel* chan = srslog::create_log_channel("basic_hex_test", *s);
if (!chan) {
return SRSLTE_ERROR;
}
srslte::srslog_wrapper l(*chan);
log_filter filter("layer", &l);
filter.set_level(LOG_LEVEL_DEBUG);
@ -183,11 +194,10 @@ int test_log_ref()
int full_test()
{
bool result;
std::string f("log.txt");
write(f);
#if 0
result = read(f);
bool result = read(f);
remove(f.c_str());
if(result) {
printf("Passed\n");
@ -203,6 +213,12 @@ int full_test()
int main(int argc, char** argv)
{
// Setup logging.
srslog::sink* log_sink = srslog::create_stdout_sink();
if (!log_sink) {
return SRSLTE_ERROR;
}
TESTASSERT(basic_hex_test() == SRSLTE_SUCCESS);
TESTASSERT(full_test() == SRSLTE_SUCCESS);
TESTASSERT(test_log_singleton() == SRSLTE_SUCCESS);

@ -1,115 +0,0 @@
/*
* Copyright 2013-2020 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#define NTHREADS 100
#define NMSGS 100
#include "srslte/common/logger_file.h"
#include <stdio.h>
#include <stdlib.h>
using namespace srslte;
typedef struct {
logger_file* l;
int thread_id;
} args_t;
void* thread_loop(void* a)
{
args_t* args = (args_t*)a;
char buf[100];
for (int i = 0; i < NMSGS; i++) {
sprintf(buf, "Thread %d: %d", args->thread_id, i);
args->l->log_char(buf);
}
return NULL;
}
void write(std::string filename)
{
logger_file l;
l.init(filename);
pthread_t threads[NTHREADS];
args_t args[NTHREADS];
for (int i = 0; i < NTHREADS; i++) {
args[i].l = &l;
args[i].thread_id = i;
pthread_create(&threads[i], NULL, &thread_loop, &args[i]);
}
for (int i = 0; i < NTHREADS; i++) {
pthread_join(threads[i], NULL);
}
}
bool read(std::string filename)
{
bool pass = true;
bool written[NTHREADS][NMSGS];
int thread = 0, msg = 0;
int r;
for (int i = 0; i < NTHREADS; i++) {
for (int j = 0; j < NMSGS; j++) {
written[i][j] = false;
}
}
FILE* f = fopen(filename.c_str(), "r");
if (f != NULL) {
while (fscanf(f, "Thread %d: %d\n", &thread, &msg)) {
if (thread < NTHREADS && msg < NMSGS) {
written[thread][msg] = true;
} else {
perror("Wrong thread and/or msg");
fclose(f);
return false;
}
}
fclose(f);
}
for (int i = 0; i < NTHREADS; i++) {
for (int j = 0; j < NMSGS; j++) {
if (!written[i][j])
pass = false;
}
}
return pass;
}
int main(int argc, char** argv)
{
bool result;
std::string f("log.txt");
write(f);
result = read(f);
if (remove(f.c_str())) {
perror("Removing file");
}
if (result) {
printf("Passed\n");
exit(0);
} else {
printf("Failed\n;");
exit(1);
}
}

@ -20,7 +20,6 @@
*/
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_stdout.h"
#include "srslte/common/rlc_pcap.h"
#include "srslte/common/test_common.h"
#include "srslte/common/threads.h"

@ -21,7 +21,6 @@
#include "srslte/common/crash_handler.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_stdout.h"
#include "srslte/common/rlc_pcap.h"
#include "srslte/common/threads.h"
#include "srslte/upper/rlc.h"

@ -45,7 +45,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/interfaces_common.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_file.h"
#include "srslte/common/mac_pcap.h"
#include "srslte/common/security.h"
#include "srslte/interfaces/enb_metrics_interface.h"
@ -144,8 +143,6 @@ private:
std::unique_ptr<srslte::radio_base> radio = nullptr;
std::unique_ptr<enb_phy_base> phy = nullptr;
srslte::logger_stdout logger_stdout;
srslte::logger_file logger_file;
srslte::logger* logger = nullptr;
srslte::log_ref log; // Own logger for eNB

@ -36,8 +36,8 @@ add_library(enb_cfg_parser parser.cc enb_cfg_parser.cc)
add_executable(srsenb main.cc enb.cc metrics_stdout.cc metrics_csv.cc)
set(SRSENB_SOURCES srsenb_phy srsenb_stack srsenb_upper srsenb_mac srsenb_rrc)
set(SRSLTE_SOURCES srslte_common srslte_mac srslte_phy srslte_upper srslte_radio rrc_asn1 s1ap_asn1 enb_cfg_parser)
set(SRSENB_SOURCES srsenb_phy srsenb_stack srsenb_upper srsenb_mac srsenb_rrc srslog)
set(SRSLTE_SOURCES srslte_common srslte_mac srslte_phy srslte_upper srslte_radio rrc_asn1 s1ap_asn1 enb_cfg_parser srslog)
if(ENABLE_5GNR)
set(SRSENB_SOURCES ${SRSENB_SOURCES} srsgnb_phy srsgnb_stack srsgnb_upper srsgnb_mac srsgnb_rrc)

@ -28,7 +28,9 @@
#include "srslte/common/common_helper.h"
#include "srslte/common/config_file.h"
#include "srslte/common/crash_handler.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/common/signal_handler.h"
#include "srslte/srslog/srslog.h"
#include <boost/program_options.hpp>
#include <boost/program_options/parsers.hpp>
@ -416,6 +418,12 @@ void* input_loop(void* m)
return nullptr;
}
/// Adjusts the input value in args from kbytes to bytes.
static size_t fixup_log_file_maxsize(int x)
{
return (x < 0) ? 0 : size_t(x) * 1024u;
}
int main(int argc, char* argv[])
{
srslte_register_signal_handler();
@ -428,23 +436,30 @@ int main(int argc, char* argv[])
srslte_debug_handle_crash(argc, argv);
parse_args(&args, argc, argv);
srslte::logger_stdout logger_stdout;
// Setup logging.
log_sink = (args.log.filename == "stdout")
? srslog::create_stdout_sink()
: srslog::create_file_sink(args.log.filename, fixup_log_file_maxsize(args.log.file_max_size));
if (!log_sink) {
return SRSLTE_ERROR;
}
// Set logger
srslte::logger* logger = nullptr;
if (args.log.filename == "stdout") {
logger = &logger_stdout;
} else {
logger_file.init(args.log.filename, args.log.file_max_size);
logger = &logger_file;
srslog::log_channel* chan = srslog::create_log_channel("main_channel", *log_sink);
if (!chan) {
return SRSLTE_ERROR;
}
srslte::logmap::set_default_logger(logger);
srslte::srslog_wrapper log_wrapper(*chan);
// Start the log backend.
srslog::init();
srslte::logmap::set_default_logger(&log_wrapper);
srslte::logmap::get("COMMON")->set_level(srslte::LOG_LEVEL_INFO);
log_args(argc, argv, "ENB");
// Create eNB
unique_ptr<srsenb::enb> enb{new srsenb::enb};
if (enb->init(args, logger) != SRSLTE_SUCCESS) {
if (enb->init(args, &log_wrapper) != SRSLTE_SUCCESS) {
enb->stop();
return SRSLTE_ERROR;
}

@ -47,7 +47,7 @@ set_tests_properties(enb_phy_test_tm1 PROPERTIES LABELS "long;phy;srsenb")
# - Single carrier
# - Transmission Mode 2
# - 1 eNb cell/carrier (no carrier aggregation)
# - 6 PRB
# - 100 PRB
add_test(enb_phy_test_tm2 enb_phy_test --duration=${ENB_PHY_TEST_DURATION} --cell.nof_prb=100 --tm=2)
set_tests_properties(enb_phy_test_tm2 PROPERTIES LABELS "long;phy;srsenb")
@ -55,7 +55,7 @@ set_tests_properties(enb_phy_test_tm2 PROPERTIES LABELS "long;phy;srsenb")
# - Single carrier
# - Transmission Mode 3
# - 1 eNb cell/carrier (no carrier aggregation)
# - 6 PRB
# - 100 PRB
add_test(enb_phy_test_tm3 enb_phy_test --duration=${ENB_PHY_TEST_DURATION} --cell.nof_prb=100 --tm=3)
set_tests_properties(enb_phy_test_tm3 PROPERTIES LABELS "long;phy;srsenb")
@ -63,7 +63,7 @@ set_tests_properties(enb_phy_test_tm3 PROPERTIES LABELS "long;phy;srsenb")
# - Single carrier
# - Transmission Mode 4
# - 1 eNb cell/carrier (no carrier aggregation)
# - 6 PRB
# - 100 PRB
add_test(enb_phy_test_tm4 enb_phy_test --duration=${ENB_PHY_TEST_DURATION} --cell.nof_prb=100 --tm=4)
set_tests_properties(enb_phy_test_tm4 PROPERTIES LABELS "long;phy;srsenb")

@ -24,6 +24,7 @@
#include <iostream>
#include <mutex>
#include <srsenb/hdr/phy/phy.h>
#include <srslte/common/logger_srslog_wrapper.h>
#include <srslte/common/string_helpers.h>
#include <srslte/common/test_common.h>
#include <srslte/common/threads.h>
@ -31,6 +32,7 @@
#include <srslte/phy/common/phy_common.h>
#include <srslte/phy/phch/pusch_cfg.h>
#include <srslte/phy/utils/random.h>
#include <srslte/srslog/srslog.h>
#include <srslte/srslte.h>
static inline bool dl_ack_value(uint32_t ue_cc_idx, uint32_t tti)
@ -1176,7 +1178,6 @@ private:
unique_srsenb_phy_t enb_phy;
unique_dummy_ue_phy_t ue_phy;
srslte::log_filter log_h;
srslte::logger_stdout logger_stdout;
args_t args = {}; ///< Test arguments
srsenb::phy_args_t phy_args; ///< PHY arguments
@ -1192,7 +1193,7 @@ private:
change_state_t change_state = change_state_assert;
public:
explicit phy_test_bench(args_t& args_) : log_h("TEST BENCH")
phy_test_bench(args_t& args_, srslte::logger& logger_) : log_h("TEST BENCH")
{
// Copy test arguments
args = args_;
@ -1290,7 +1291,7 @@ public:
stack->set_active_cell_list(args.ue_cell_list);
/// eNb PHY initialisation instance
enb_phy = unique_srsenb_phy_t(new srsenb::phy(&logger_stdout));
enb_phy = unique_srsenb_phy_t(new srsenb::phy(&logger_));
/// Initiate eNb PHY with the given RNTI
enb_phy->init(phy_args, phy_cfg, radio.get(), stack.get());
@ -1446,8 +1447,20 @@ int main(int argc, char** argv)
// Initialize secondary parameters
test_args.init();
// 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);
// Create Test Bench
unique_phy_test_bench test_bench = unique_phy_test_bench(new phy_test_bench(test_args));
unique_phy_test_bench test_bench = unique_phy_test_bench(new phy_test_bench(test_args, log_wrapper));
// Run Simulation
for (uint32_t i = 0; i < test_args.duration; i++) {

@ -44,7 +44,6 @@ int test_cell_cfg(const srsenb::sched_interface::cell_cfg_t& cellcfg)
*/
int test_sib_generation()
{
srslte::logger_stdout logger;
srslte::timer_handler timers_db(128);
mac_dummy mac_obj;
@ -73,7 +72,6 @@ int test_sib_generation()
int test_rrc_setup()
{
srslte::logger_stdout logger;
srslte::timer_handler timers_db(128);
mac_dummy mac_obj;

@ -31,7 +31,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_file.h"
#include "srslte/interfaces/epc_interfaces.h"
#include <cstddef>
#include <fstream>

@ -31,7 +31,6 @@
#include "srslte/asn1/gtpc.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_file.h"
#include "srslte/common/logmap.h"
#include "srslte/common/threads.h"
#include "srslte/srslte.h"

@ -32,7 +32,6 @@
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_file.h"
#include "srslte/common/threads.h"
#include <cstddef>

@ -31,7 +31,6 @@
#include "srslte/asn1/gtpc.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_file.h"
#include "srslte/common/logmap.h"
#include "srslte/common/threads.h"
#include <cstddef>

@ -41,6 +41,7 @@ target_link_libraries( srsepc srsepc_mme
s1ap_asn1
srslte_upper
srslte_common
srslog
${CMAKE_THREAD_LIBS_INIT}
${Boost_LIBRARIES}
${SEC_LIBRARIES}
@ -51,6 +52,7 @@ add_executable(srsmbms mbms-gw/main.cc )
target_link_libraries(srsmbms srsepc_mbms_gw
srslte_upper
srslte_common
srslog
${CMAKE_THREAD_LIBS_INIT}
${Boost_LIBRARIES}
${SEC_LIBRARIES}

@ -27,7 +27,9 @@
#include "srslte/common/common_helper.h"
#include "srslte/common/config_file.h"
#include "srslte/common/crash_handler.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/common/signal_handler.h"
#include "srslte/srslog/srslog.h"
#include <boost/program_options.hpp>
#include <iostream>
#include <signal.h>
@ -386,44 +388,52 @@ int main(int argc, char* argv[])
all_args_t args;
parse_args(&args, argc, argv);
srslte::logger_stdout logger_stdout;
srslte::logger* logger;
// Setup logging.
log_sink = (args.log_args.filename == "stdout") ? srslog::create_stdout_sink()
: srslog::create_file_sink(args.log_args.filename);
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);
/*Init logger*/
if (args.log_args.filename == "stdout") {
logger = &logger_stdout;
} else {
logger_file.init(args.log_args.filename);
logger_file.log_char("\n\n");
logger_file.log_char(get_build_string().c_str());
logger_file.log_char("\n--- Software Radio Systems EPC log ---\n\n");
logger = &logger_file;
// Start the log backend.
srslog::init();
if (args.log_args.filename != "stdout") {
log_wrapper.log_char("\n\n");
log_wrapper.log_char(get_build_string().c_str());
log_wrapper.log_char("\n--- Software Radio Systems EPC log ---\n\n");
}
srslte::logmap::set_default_logger(logger);
srslte::logmap::set_default_logger(&log_wrapper);
log_args(argc, argv, "EPC");
srslte::log_filter nas_log;
nas_log.init("NAS ", logger);
nas_log.init("NAS ", &log_wrapper);
nas_log.set_level(level(args.log_args.nas_level));
nas_log.set_hex_limit(args.log_args.nas_hex_limit);
srslte::log_filter s1ap_log;
s1ap_log.init("S1AP", logger);
s1ap_log.init("S1AP", &log_wrapper);
s1ap_log.set_level(level(args.log_args.s1ap_level));
s1ap_log.set_hex_limit(args.log_args.s1ap_hex_limit);
srslte::log_filter mme_gtpc_log;
mme_gtpc_log.init("MME GTPC", logger);
mme_gtpc_log.init("MME GTPC", &log_wrapper);
mme_gtpc_log.set_level(level(args.log_args.mme_gtpc_level));
mme_gtpc_log.set_hex_limit(args.log_args.mme_gtpc_hex_limit);
srslte::log_filter hss_log;
hss_log.init("HSS ", logger);
hss_log.init("HSS ", &log_wrapper);
hss_log.set_level(level(args.log_args.hss_level));
hss_log.set_hex_limit(args.log_args.hss_hex_limit);
srslte::log_filter spgw_gtpc_log;
spgw_gtpc_log.init("SPGW GTPC", logger);
spgw_gtpc_log.init("SPGW GTPC", &log_wrapper);
spgw_gtpc_log.set_level(level(args.log_args.spgw_gtpc_level));
spgw_gtpc_log.set_hex_limit(args.log_args.spgw_gtpc_hex_limit);
@ -432,7 +442,7 @@ int main(int argc, char* argv[])
gtpu_log->set_hex_limit(args.log_args.mme_gtpc_hex_limit);
srslte::log_filter spgw_log;
spgw_log.init("SPGW", logger);
spgw_log.init("SPGW", &log_wrapper);
spgw_log.set_level(level(args.log_args.spgw_level));
spgw_log.set_hex_limit(args.log_args.spgw_hex_limit);

@ -18,8 +18,11 @@
* and at http://www.gnu.org/licenses/.
*
*/
#include "srsepc/hdr/mbms-gw/mbms-gw.h"
#include "srslte/common/config_file.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/srslog/srslog.h"
#include <boost/program_options.hpp>
#include <iostream>
#include <signal.h>
@ -192,19 +195,25 @@ int main(int argc, char* argv[])
all_args_t args;
parse_args(&args, argc, argv);
srslte::logger_stdout logger_stdout;
srslte::logger_file logger_file;
srslte::logger* logger;
srslog::sink* log_sink = (args.log_args.filename == "stdout") ? srslog::create_stdout_sink()
: srslog::create_file_sink(args.log_args.filename);
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);
// Start the log backend.
srslog::init();
/*Init logger*/
if (!args.log_args.filename.compare("stdout")) {
logger = &logger_stdout;
} else {
logger_file.init(args.log_args.filename);
logger_file.log_char("\n--- Software Radio Systems MBMS log ---\n\n");
logger = &logger_file;
if (args.log_args.filename != "stdout") {
log_wrapper.log_char("\n--- Software Radio Systems MBMS log ---\n\n");
}
srslte::logmap::set_default_logger(logger);
srslte::logmap::set_default_logger(&log_wrapper);
srslte::log_ref mbms_gw_log{"MBMS"};
mbms_gw_log->set_level(level(args.log_args.mbms_gw_level));

@ -25,6 +25,7 @@
#include "srslte/common/security.h"
#include <cmath>
#include <inttypes.h> // for printing uint64_t
#include <sys/timerfd.h>
namespace srsepc {

@ -35,7 +35,6 @@
#include "phy/ue_phy_base.h"
#include "srslte/common/buffer_pool.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_file.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/radio/radio.h"
#include "stack/ue_stack_base.h"

@ -18,9 +18,12 @@
* and at http://www.gnu.org/licenses/.
*
*/
#include <srslte/common/logger_srslog_wrapper.h>
#include <srslte/common/test_common.h>
#include <srslte/common/threads.h>
#include <srslte/phy/utils/random.h>
#include <srslte/srslog/srslog.h>
#include <srslte/srslte.h>
#include <srsue/hdr/phy/phy.h>
@ -320,7 +323,6 @@ private:
};
// Common instances
srslte::logger_stdout main_logger;
srslte::log_filter log_h;
// Dummy instances
@ -343,9 +345,9 @@ private:
std::condition_variable cvar;
public:
phy_test_bench(const srsue::phy_args_t& phy_args, const srslte_cell_t& cell) :
stack(main_logger),
radio(main_logger, cell.nof_ports, srslte_sampling_freq_hz(cell.nof_prb)),
phy_test_bench(const srsue::phy_args_t& phy_args, const srslte_cell_t& cell, srslte::logger& logger_) :
stack(logger_),
radio(logger_, cell.nof_ports, srslte_sampling_freq_hz(cell.nof_prb)),
thread("phy_test_bench"),
log_h("test bench")
{
@ -353,7 +355,7 @@ public:
sf_len = SRSLTE_SF_LEN_PRB(cell.nof_prb);
// Initialise UE
phy = std::unique_ptr<srsue::phy>(new srsue::phy(&main_logger));
phy = std::unique_ptr<srsue::phy>(new srsue::phy(&logger_));
phy->init(phy_args, &stack, &radio);
// Initialise DL baseband buffers
@ -481,8 +483,23 @@ int main(int argc, char** argv)
// Set custom test cell and arguments here
phy_args.log.phy_level = "info";
// 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);
// Start the log backend.
srslog::init();
// Create test bench
std::unique_ptr<phy_test_bench> phy_test = std::unique_ptr<phy_test_bench>(new phy_test_bench(phy_args, cell));
std::unique_ptr<phy_test_bench> phy_test =
std::unique_ptr<phy_test_bench>(new phy_test_bench(phy_args, cell, log_wrapper));
phy_test->set_loglevel("info");
// Start test bench

@ -49,7 +49,7 @@ class ttcn3_syssim : public syssim_interface_phy,
public srslte::pdu_queue::process_callback
{
public:
ttcn3_syssim(srslte::logger_file* logger_file_, ttcn3_ue* ue_);
ttcn3_syssim(srslte::logger& logger_file_, srslte::logger& logger_stdout_, ttcn3_ue* ue_);
~ttcn3_syssim();
@ -225,9 +225,10 @@ private:
epoll_signal_handler signal_handler;
// Logging stuff
srslte::logger_stdout logger_stdout;
srslte::logger_file* logger_file = nullptr;
srslte::logger* logger = nullptr;
srslte::logger& logger_stdout;
srslte::logger& logger_file;
std::unique_ptr<logger> test_case_logger;
srslte::logger* logger_ptr = nullptr;
srslte::log_ref log;
srslte::log_filter ut_log;
srslte::log_filter sys_log;

@ -20,7 +20,9 @@
*/
#include "srslte/build_info.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/common/logmap.h"
#include "srslte/srslog/srslog.h"
#include "srsue/hdr/ue.h"
#include "ttcn3_syssim.h"
#include <boost/program_options.hpp>
@ -118,15 +120,37 @@ int main(int argc, char** argv)
ttcn3_dut_args_t dut_args = {};
all_args_t ue_args = parse_args(&dut_args, argc, argv);
// Setup logging.
srslog::sink* log_file_sink = srslog::create_file_sink(dut_args.log_filename);
if (!log_file_sink) {
return SRSLTE_ERROR;
}
srslog::log_channel* file_chan = srslog::create_log_channel("file_channel", *log_file_sink);
if (!file_chan) {
return SRSLTE_ERROR;
}
srslog::sink* stdout_sink = srslog::create_stdout_sink();
if (!stdout_sink) {
return SRSLTE_ERROR;
}
srslog::log_channel* stdout_chan = srslog::create_log_channel("stdout_channel", *stdout_sink);
if (!stdout_chan) {
return SRSLTE_ERROR;
}
srslte::srslog_wrapper stdout_wrapper(*stdout_chan);
srslte::srslog_wrapper file_wrapper(*file_chan);
// Start the log backend.
srslog::init();
// Instantiate file logger
srslte::logger_file logger_file;
srslte::logmap::set_default_logger(&logger_file);
srslte::logmap::set_default_logger(&file_wrapper);
// Create UE object
unique_ptr<ttcn3_ue> ue = std::unique_ptr<ttcn3_ue>(new ttcn3_ue());
// create and init SYSSIM
ttcn3_syssim syssim(&logger_file, ue.get());
ttcn3_syssim syssim(file_wrapper, stdout_wrapper, ue.get());
if (syssim.init(ue_args) != SRSLTE_SUCCESS) {
fprintf(stderr, "Error: Couldn't initialize system simulator\n");
return SRSLTE_ERROR;

@ -21,7 +21,9 @@
#include "srsue/test/ttcn3/hdr/ttcn3_syssim.h"
#include "dut_utils.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/mac/pdu_queue.h"
#include "srslte/srslog/srslog.h"
#include "srslte/test/ue_test_interfaces.h"
#include "srslte/upper/pdcp.h"
#include "srslte/upper/rlc.h"
@ -35,13 +37,14 @@
#include "ttcn3_ut_interface.h"
#include <functional>
ttcn3_syssim::ttcn3_syssim(srslte::logger_file* logger_file_, ttcn3_ue* ue_) :
ttcn3_syssim::ttcn3_syssim(srslte::logger& logger_file_, srslte::logger& logger_stdout_, ttcn3_ue* ue_) :
log{"SS "},
mac_msg_ul(20, ss_mac_log),
mac_msg_dl(20, ss_mac_log),
pdus(128),
logger(logger_file_),
logger_stdout(logger_stdout_),
logger_file(logger_file_),
logger_ptr(&logger_file_),
pool(byte_buffer_pool::get_instance()),
ue(ue_),
rlc(ss_rlc_log->get_service_name().c_str()),
@ -49,7 +52,7 @@ ttcn3_syssim::ttcn3_syssim(srslte::logger_file* logger_file_, ttcn3_ue* ue_) :
timer_handler(create_tti_timer(), [&](uint64_t res) { new_tti_indication(res); }),
pdcp(&stack.task_sched, ss_pdcp_log->get_service_name().c_str())
{
if (ue->init(all_args_t{}, logger, this, "INIT_TEST") != SRSLTE_SUCCESS) {
if (ue->init(all_args_t{}, logger_ptr, this, "INIT_TEST") != SRSLTE_SUCCESS) {
ue->stop();
fprintf(stderr, "Couldn't initialize UE.\n");
}
@ -63,20 +66,20 @@ int ttcn3_syssim::init(const all_args_t& args_)
// Make sure to get SS logging as well
if (args.log.filename == "stdout") {
logger = &logger_stdout;
logger_ptr = &logger_stdout;
}
srslte::logmap::set_default_logger(logger);
srslte::logmap::set_default_logger(logger_ptr);
// init and configure logging
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS ", logger, true}});
ut_log.init("UT ", logger);
sys_log.init("SYS ", logger);
ip_sock_log.init("IP_S", logger);
ip_ctrl_log.init("IP_C", logger);
srb_log.init("SRB ", logger);
drb_log.init("DRB ", logger);
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-RLC", logger}});
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-PDCP", logger}});
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS ", logger_ptr, true}});
ut_log.init("UT ", logger_ptr);
sys_log.init("SYS ", logger_ptr);
ip_sock_log.init("IP_S", logger_ptr);
ip_ctrl_log.init("IP_C", logger_ptr);
srb_log.init("SRB ", logger_ptr);
drb_log.init("DRB ", logger_ptr);
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-RLC", logger_ptr}});
srslte::logmap::register_log(std::unique_ptr<srslte::log>{new log_filter{"SS-PDCP", logger_ptr}});
log->set_level(args.log.all_level);
ut_log.set_level(args.log.all_level);
@ -405,10 +408,13 @@ void ttcn3_syssim::tc_start(const char* name)
// set up logging
if (args.log.filename == "stdout") {
logger = &logger_stdout;
logger_ptr = &logger_stdout;
} else {
logger_file->init(get_filename_with_tc_name(local_args.log.filename, run_id, tc_name).c_str(), -1);
logger = logger_file;
const std::string& file_tc_name = get_filename_with_tc_name(local_args.log.filename, run_id, tc_name);
srslog::sink* s = srslog::create_file_sink(file_tc_name);
srslog::log_channel* c = srslog::create_log_channel(file_tc_name, *s);
test_case_logger = std::unique_ptr<srslte::logger>(new srslte::srslog_wrapper(*c));
logger_ptr = test_case_logger.get();
}
log->info("Initializing UE ID=%d for TC=%s\n", run_id, tc_name.c_str());
@ -419,7 +425,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, logger, this, tc_name)) {
if (ue->init(local_args, logger_ptr, this, tc_name)) {
ue->stop();
std::string err("Couldn't initialize UE.\n");
log->error("%s\n", err.c_str());
@ -444,8 +450,6 @@ void ttcn3_syssim::tc_end()
// stop TTI timer
del_epoll(timer_handler.get_timer_fd(), epoll_fd);
logger_file->stop();
run_id++;
// Reset SS' RLC and PDCP

@ -21,8 +21,10 @@
#include "srslte/common/bcd_helpers.h"
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_srslog_wrapper.h"
#include "srslte/common/logmap.h"
#include "srslte/interfaces/ue_interfaces.h"
#include "srslte/srslog/srslog.h"
#include "srslte/test/ue_test_interfaces.h"
#include "srslte/upper/pdcp.h"
#include "srslte/upper/pdcp_entity_lte.h"
@ -269,6 +271,14 @@ int mme_attach_request_test()
srslte::log_filter usim_log("USIM");
srslte::log_filter gw_log("GW");
// Setup logging.
srslog::sink *log_sink = srslog::find_sink("stdout");
srslog::log_channel* chan = srslog::create_log_channel("mme_attach_request_test", *log_sink);
srslte::srslog_wrapper log_wrapper(*chan);
// Start the log backend.
srslog::init();
rrc_log.set_level(srslte::LOG_LEVEL_DEBUG);
usim_log.set_level(srslte::LOG_LEVEL_DEBUG);
gw_log.set_level(srslte::LOG_LEVEL_DEBUG);
@ -293,6 +303,7 @@ int mme_attach_request_test()
nas_args_t nas_cfg;
nas_cfg.force_imsi_attach = true;
nas_cfg.apn_name = "test123";
test_stack_dummy stack(&pdcp_dummy);
srsue::nas nas(&stack.task_sched);
srsue::gw gw;
@ -304,8 +315,8 @@ int mme_attach_request_test()
gw_args.tun_dev_name = "tun0";
gw_args.log.gw_level = "debug";
gw_args.log.gw_hex_limit = 100000;
srslte::logger_stdout def_logstdout;
srslte::logger* logger = &def_logstdout;
srslte::logger* logger = &log_wrapper;
gw.init(gw_args, logger, &stack);
stack.init(&nas);

Loading…
Cancel
Save