- Add date to log timestamps.

- Print once per second the current timestamp into stdout, feature guarded by a config expert option.
master
faluco 4 years ago committed by Ismael Gomez
parent 67325ab5c1
commit 8708043a5f

@ -43,7 +43,7 @@ static void format_metadata(const detail::log_entry_metadata& metadata, fmt::mem
std::tm current_time = fmt::gmtime(std::chrono::high_resolution_clock::to_time_t(metadata.tp)); std::tm current_time = fmt::gmtime(std::chrono::high_resolution_clock::to_time_t(metadata.tp));
auto us_fraction = auto us_fraction =
std::chrono::duration_cast<std::chrono::microseconds>(metadata.tp.time_since_epoch()).count() % 1000000u; std::chrono::duration_cast<std::chrono::microseconds>(metadata.tp.time_since_epoch()).count() % 1000000u;
fmt::format_to(buffer, "{:%H:%M:%S}.{:06} ", current_time, us_fraction); fmt::format_to(buffer, "{:%F}T{:%H:%M:%S}.{:06} ", current_time, current_time, us_fraction);
// Format optional fields if present. // Format optional fields if present.
if (!metadata.log_name.empty()) { if (!metadata.log_name.empty()) {

@ -326,6 +326,7 @@ enable = false
# tracing_enable: Write source code tracing information to a file. # tracing_enable: Write source code tracing information to a file.
# tracing_filename: File path to use for tracing information. # tracing_filename: File path to use for tracing information.
# tracing_buffcapacity: Maximum capacity in bytes the tracing framework can store. # tracing_buffcapacity: Maximum capacity in bytes the tracing framework can store.
# stdout_ts_enable: Prints once per second the timestamp into stdout.
# pregenerate_signals: Pregenerate uplink signals after attach. Improves CPU performance. # pregenerate_signals: Pregenerate uplink signals after attach. Improves CPU performance.
# tx_amplitude: Transmit amplitude factor (set 0-1 to reduce PAPR) # tx_amplitude: Transmit amplitude factor (set 0-1 to reduce PAPR)
# rrc_inactivity_timer Inactivity timeout used to remove UE context from RRC (in milliseconds). # rrc_inactivity_timer Inactivity timeout used to remove UE context from RRC (in milliseconds).
@ -353,6 +354,7 @@ enable = false
#tracing_enable = true #tracing_enable = true
#tracing_filename = /tmp/enb_tracing.log #tracing_filename = /tmp/enb_tracing.log
#tracing_buffcapacity = 1000000 #tracing_buffcapacity = 1000000
#stdout_ts_enable = false
#pregenerate_signals = false #pregenerate_signals = false
#tx_amplitude = 0.6 #tx_amplitude = 0.6
#rrc_inactivity_timer = 30000 #rrc_inactivity_timer = 30000

@ -45,7 +45,8 @@ namespace bpo = boost::program_options;
/********************************************************************** /**********************************************************************
* Program arguments processing * Program arguments processing
***********************************************************************/ ***********************************************************************/
string config_file; string config_file;
static bool stdout_ts_enable = false;
void parse_args(all_args_t* args, int argc, char* argv[]) void parse_args(all_args_t* args, int argc, char* argv[])
{ {
@ -226,6 +227,7 @@ void parse_args(all_args_t* args, int argc, char* argv[])
("expert.tracing_enable", bpo::value<bool>(&args->general.tracing_enable)->default_value(false), "Events tracing") ("expert.tracing_enable", bpo::value<bool>(&args->general.tracing_enable)->default_value(false), "Events tracing")
("expert.tracing_filename", bpo::value<string>(&args->general.tracing_filename)->default_value("/tmp/enb_tracing.log"), "Tracing events filename") ("expert.tracing_filename", bpo::value<string>(&args->general.tracing_filename)->default_value("/tmp/enb_tracing.log"), "Tracing events filename")
("expert.tracing_buffcapacity", bpo::value<std::size_t>(&args->general.tracing_buffcapacity)->default_value(1000000), "Tracing buffer capcity") ("expert.tracing_buffcapacity", bpo::value<std::size_t>(&args->general.tracing_buffcapacity)->default_value(1000000), "Tracing buffer capcity")
("expert.stdout_ts_enable", bpo::value<bool>(&stdout_ts_enable)->default_value(false), "Prints once per second the timestamp into stdout")
("expert.rrc_inactivity_timer", bpo::value<uint32_t>(&args->general.rrc_inactivity_timer)->default_value(30000), "Inactivity timer in ms.") ("expert.rrc_inactivity_timer", bpo::value<uint32_t>(&args->general.rrc_inactivity_timer)->default_value(30000), "Inactivity timer in ms.")
("expert.print_buffer_state", bpo::value<bool>(&args->general.print_buffer_state)->default_value(false), "Prints on the console the buffer state every 10 seconds") ("expert.print_buffer_state", bpo::value<bool>(&args->general.print_buffer_state)->default_value(false), "Prints on the console the buffer state every 10 seconds")
("expert.eea_pref_list", bpo::value<string>(&args->general.eea_pref_list)->default_value("EEA0, EEA2, EEA1"), "Ordered preference list for the selection of encryption algorithm (EEA) (default: EEA0, EEA2, EEA1).") ("expert.eea_pref_list", bpo::value<string>(&args->general.eea_pref_list)->default_value("EEA0, EEA2, EEA1"), "Ordered preference list for the selection of encryption algorithm (EEA) (default: EEA0, EEA2, EEA1).")
@ -622,7 +624,8 @@ int main(int argc, char* argv[])
enb->start_plot(); enb->start_plot();
} }
} }
int cnt = 0; int cnt = 0;
int ts_cnt = 0;
while (running) { while (running) {
if (args.general.print_buffer_state) { if (args.general.print_buffer_state) {
cnt++; cnt++;
@ -631,6 +634,16 @@ int main(int argc, char* argv[])
enb->print_pool(); enb->print_pool();
} }
} }
if (stdout_ts_enable) {
if (++ts_cnt == 100) {
ts_cnt = 0;
char buff[64];
std::time_t t = std::time(nullptr);
if (std::strftime(buff, sizeof(buff), "%FT%T", std::gmtime(&t))) {
std::cout << buff << '\n';
}
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(10)); std::this_thread::sleep_for(std::chrono::milliseconds(10));
} }
input.join(); input.join();

Loading…
Cancel
Save