create simple helper method to log command line arguments

master
Andre Puschmann 4 years ago
parent db7478e9f0
commit 8512c10286

@ -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

@ -25,6 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "srslte/common/common_helper.h"
#include "srslte/common/config_file.h" #include "srslte/common/config_file.h"
#include "srslte/common/crash_handler.h" #include "srslte/common/crash_handler.h"
#include "srslte/common/signal_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::set_default_logger(logger);
srslte::logmap::get("COMMON")->set_level(srslte::LOG_LEVEL_INFO); srslte::logmap::get("COMMON")->set_level(srslte::LOG_LEVEL_INFO);
log_args(argc, argv, "ENB");
// Create eNB // Create eNB
unique_ptr<srsenb::enb> enb{new srsenb::enb}; unique_ptr<srsenb::enb> enb{new srsenb::enb};

@ -24,6 +24,7 @@
#include "srsepc/hdr/spgw/spgw.h" #include "srsepc/hdr/spgw/spgw.h"
#include "srslte/build_info.h" #include "srslte/build_info.h"
#include "srslte/common/bcd_helpers.h" #include "srslte/common/bcd_helpers.h"
#include "srslte/common/common_helper.h"
#include "srslte/common/config_file.h" #include "srslte/common/config_file.h"
#include "srslte/common/crash_handler.h" #include "srslte/common/crash_handler.h"
#include "srslte/common/signal_handler.h" #include "srslte/common/signal_handler.h"
@ -399,6 +400,7 @@ int main(int argc, char* argv[])
logger = &logger_file; logger = &logger_file;
} }
srslte::logmap::set_default_logger(logger); srslte::logmap::set_default_logger(logger);
log_args(argc, argv, "EPC");
srslte::log_filter nas_log; srslte::log_filter nas_log;
nas_log.init("NAS ", logger); nas_log.init("NAS ", logger);

@ -19,6 +19,7 @@
* *
*/ */
#include "srslte/common/common_helper.h"
#include "srslte/common/config_file.h" #include "srslte/common/config_file.h"
#include "srslte/common/crash_handler.h" #include "srslte/common/crash_handler.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
@ -600,6 +601,7 @@ int main(int argc, char* argv[])
logger = &logger_file; logger = &logger_file;
} }
srslte::logmap::set_default_logger(logger); srslte::logmap::set_default_logger(logger);
log_args(argc, argv, "UE");
// Create UE instance // Create UE instance
srsue::ue ue; srsue::ue ue;

Loading…
Cancel
Save