Skip to content

Commit

Permalink
Merge pull request #735 from tadscottsmith/fix-min-tx-logging
Browse files Browse the repository at this point in the history
Fix logging when all transmissions are removed.
  • Loading branch information
robotastic committed Nov 25, 2022
2 parents fe2eecb + 78db149 commit eb1e453
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions trunk-recorder/call_concluder/call_concluder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ Call_Data_t Call_Concluder::create_call_data(Call *call, System *sys, Config con
call_info.compress_wav = sys->get_compress_wav();
call_info.talkgroup = call->get_talkgroup();
call_info.patched_talkgroups = sys->get_talkgroup_patch(call_info.talkgroup);
call_info.min_transmissions_removed = 0;

Talkgroup *tg = sys->find_talkgroup(call->get_talkgroup());
if (tg != NULL) {
Expand Down Expand Up @@ -268,7 +269,9 @@ Call_Data_t Call_Concluder::create_call_data(Call *call, System *sys, Config con

snprintf(formattedTalkgroup, 61, "%c[%dm%10ld%c[0m", 0x1B, 35, call_info.talkgroup, 0x1B);
std::string talkgroup_display = boost::lexical_cast<std::string>(formattedTalkgroup);
BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tRemoving transmission less than " << sys->get_min_tx_duration() << " seconds. Actual length: " << t.length << "." << std::endl;
BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tRemoving transmission less than " << sys->get_min_tx_duration() << " seconds. Actual length: " << t.length << ".";

call_info.min_transmissions_removed++;

if (checkIfFile(t.filename)) {
remove(t.filename);
Expand Down Expand Up @@ -317,8 +320,12 @@ void Call_Concluder::conclude_call(Call *call, System *sys, Config config) {
snprintf(formattedTalkgroup, 61, "%c[%dm%10ld%c[0m", 0x1B, 35, call_info.talkgroup, 0x1B);
std::string talkgroup_display = boost::lexical_cast<std::string>(formattedTalkgroup);

if (call_info.transmission_list.size() == 0) {
BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << talkgroup_display << "\t Freq: " << call_info.freq << "\tNo Transmission were recorded!";
if (call_info.transmission_list.size() == 0 && call_info.min_transmissions_removed == 0) {
BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << talkgroup_display << "\t Freq: " << call_info.freq << "\tNo Transmissions were recorded!";
return;
}
else if (call_info.transmission_list.size() == 0 && call_info.min_transmissions_removed > 0) {
BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << talkgroup_display << "\t Freq: " << call_info.freq << "\tNo Transmissions were recorded! " << call_info.min_transmissions_removed << " tranmissions less than " << sys->get_min_tx_duration() << " seconds were removed.";
return;
}

Expand Down
1 change: 1 addition & 0 deletions trunk-recorder/global_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct Call_Data_t {
char filename[300];
char status_filename[300];
char converted[300];
int min_transmissions_removed;

std::string short_name;
std::string upload_script;
Expand Down

0 comments on commit eb1e453

Please sign in to comment.