diff --git a/lib/include/srslte/common/common_helper.h b/lib/include/srslte/common/common_helper.h new file mode 100644 index 000000000..df990aa89 --- /dev/null +++ b/lib/include/srslte/common/common_helper.h @@ -0,0 +1,52 @@ +/* + * 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 common_helper.h + * @brief Common helper functions shared among srsLTE applications. + */ + +#ifndef SRSLTE_COMMON_HELPER_H +#define SRSLTE_COMMON_HELPER_H + +#include "srslte/common/logmap.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void log_args(int argc, char* argv[], std::string service) +{ + std::ostringstream s1; + s1 << "Using binary " << argv[0] << " with arguments: "; + for (int32_t i = 1; i < argc; i++) { + s1 << argv[i] << " "; + } + s1 << std::endl; + + srslte::logmap::get(service)->set_level(srslte::LOG_LEVEL_INFO); + srslte::logmap::get(service)->info("%s", s1.str().c_str()); +} + +#ifdef __cplusplus +} +#endif // __cplusplus +#endif // SRSLTE_COMMON_HELPER_H diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index ac80f1204..73c706007 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -25,6 +25,7 @@ #include #include +#include "srslte/common/common_helper.h" #include "srslte/common/config_file.h" #include "srslte/common/crash_handler.h" #include "srslte/common/signal_handler.h" @@ -421,6 +422,7 @@ int main(int argc, char* argv[]) } srslte::logmap::set_default_logger(logger); srslte::logmap::get("COMMON")->set_level(srslte::LOG_LEVEL_INFO); + log_args(argc, argv, "ENB"); // Create eNB unique_ptr enb{new srsenb::enb}; diff --git a/srsepc/src/main.cc b/srsepc/src/main.cc index 6803ac778..e393301e8 100644 --- a/srsepc/src/main.cc +++ b/srsepc/src/main.cc @@ -24,6 +24,7 @@ #include "srsepc/hdr/spgw/spgw.h" #include "srslte/build_info.h" #include "srslte/common/bcd_helpers.h" +#include "srslte/common/common_helper.h" #include "srslte/common/config_file.h" #include "srslte/common/crash_handler.h" #include "srslte/common/signal_handler.h" @@ -399,6 +400,7 @@ int main(int argc, char* argv[]) logger = &logger_file; } srslte::logmap::set_default_logger(logger); + log_args(argc, argv, "EPC"); srslte::log_filter nas_log; nas_log.init("NAS ", logger); diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 82ac0e21e..140ddf21a 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -19,6 +19,7 @@ * */ +#include "srslte/common/common_helper.h" #include "srslte/common/config_file.h" #include "srslte/common/crash_handler.h" #include "srslte/common/logmap.h" @@ -600,6 +601,7 @@ int main(int argc, char* argv[]) logger = &logger_file; } srslte::logmap::set_default_logger(logger); + log_args(argc, argv, "UE"); // Create UE instance srsue::ue ue;