diff --git a/plugins/openmhz_uploader/openmhz_uploader.cc b/plugins/openmhz_uploader/openmhz_uploader.cc index 3f2260c0c..396438e5a 100644 --- a/plugins/openmhz_uploader/openmhz_uploader.cc +++ b/plugins/openmhz_uploader/openmhz_uploader.cc @@ -291,13 +291,14 @@ class Openmhz_Uploader : public Plugin_Api { if (res == CURLM_OK && response_code == 200) { struct stat file_info; stat(call_info.converted, &file_info); - - BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tOpenMHz Upload Success - file size: " << file_info.st_size; + std::string loghdr = log_header(call_info.short_name,call_info.call_num,talkgroup_display,call_info.freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "\tOpenMHz Upload Success - file size: " << file_info.st_size; ; return 0; } } - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tOpenMHz Upload Error: " << response_buffer; + std::string loghdr = log_header(call_info.short_name,call_info.call_num,talkgroup_display,call_info.freq); + BOOST_LOG_TRIVIAL(error) << loghdr << "\tOpenMHz Upload Error: " << response_buffer; return 1; } diff --git a/plugins/rdioscanner_uploader/rdioscanner_uploader.cc b/plugins/rdioscanner_uploader/rdioscanner_uploader.cc index 7200a518a..ca664d052 100644 --- a/plugins/rdioscanner_uploader/rdioscanner_uploader.cc +++ b/plugins/rdioscanner_uploader/rdioscanner_uploader.cc @@ -115,7 +115,10 @@ class Rdio_Scanner_Uploader : public Plugin_Api { } else { patch_list << "]"; } - + char formattedTalkgroup[62]; + snprintf(formattedTalkgroup, 61, "%c[%dm%10ld%c[0m", 0x1B, 35, call_info.talkgroup, 0x1B); + std::string talkgroup_display = boost::lexical_cast(formattedTalkgroup); + std::ostringstream freq_list; std::string freq_list_string; freq_list << std::fixed << std::setprecision(2); @@ -327,13 +330,14 @@ class Rdio_Scanner_Uploader : public Plugin_Api { if (res == CURLM_OK && response_code == 200) { struct stat file_info; stat(compress_wav ? call_info.converted : call_info.filename, &file_info); - - BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tRdio Scanner Upload Success - file size: " << file_info.st_size; + std::string loghdr = log_header(call_info.short_name,call_info.call_num,talkgroup_display,call_info.freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "\tRdio Scanner Upload Success - file size: " << file_info.st_size; ; return 0; } } - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tRdio Scanner Upload Error: " << response_buffer; + std::string loghdr = log_header(call_info.short_name,call_info.call_num,talkgroup_display,call_info.freq); + BOOST_LOG_TRIVIAL(error) << loghdr << "\tRdio Scanner Upload Error: " << response_buffer; return 1; } diff --git a/trunk-recorder/call_concluder/call_concluder.cc b/trunk-recorder/call_concluder/call_concluder.cc index 0295e0748..318b61d2d 100644 --- a/trunk-recorder/call_concluder/call_concluder.cc +++ b/trunk-recorder/call_concluder/call_concluder.cc @@ -116,7 +116,8 @@ int create_call_json(Call_Data_t& call_info) { json_file << json_data.dump(2); return 0; } else { - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m \t Unable to create JSON file: " << call_info.status_filename; + std::string loghdr = log_header( call_info.short_name, call_info.call_num, call_info.talkgroup_display , call_info.freq); + BOOST_LOG_TRIVIAL(error) << loghdr << "C\033[0m \t Unable to create JSON file: " << call_info.status_filename; return 1; } } @@ -239,8 +240,8 @@ Call_Data_t upload_call_worker(Call_Data_t call_info) { if (call_info.upload_script.length() != 0) { shell_command << call_info.upload_script << " " << call_info.filename << " " << call_info.status_filename << " " << call_info.converted; shell_command_string = shell_command.str(); - - BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m \t Running upload script: " << shell_command_string; + std::string loghdr = log_header( call_info.short_name, call_info.call_num, call_info.talkgroup_display , call_info.freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "C\033[0m \t Running upload script: " << shell_command_string; result = system(shell_command_string.c_str()); } @@ -356,8 +357,8 @@ Call_Data_t Call_Concluder::create_call_data(Call *call, System *sys, Config con if (t.length < sys->get_min_tx_duration()) { if (!call_info.transmission_archive) { - - BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tRemoving transmission less than " << sys->get_min_tx_duration() << " seconds. Actual length: " << t.length << "."; + std::string loghdr = log_header( call_info.short_name, call_info.call_num, call_info.talkgroup_display , call_info.freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "\tRemoving transmission less than " << sys->get_min_tx_duration() << " seconds. Actual length: " << t.length << "."; call_info.min_transmissions_removed++; if (checkIfFile(t.filename)) { @@ -376,7 +377,8 @@ Call_Data_t Call_Concluder::create_call_data(Call *call, System *sys, Config con } std::stringstream transmission_info; - transmission_info << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\t- Transmission src: " << t.source << display_tag << " pos: " << format_time(total_length) << " length: " << format_time(t.length); + std::string loghdr = log_header( call_info.short_name, call_info.call_num, call_info.talkgroup_display , call_info.freq); + transmission_info << loghdr << "\t- Transmission src: " << t.source << display_tag << " pos: " << format_time(total_length) << " length: " << format_time(t.length); if (t.error_count < 1) { BOOST_LOG_TRIVIAL(info) << transmission_info.str(); @@ -411,22 +413,23 @@ Call_Data_t Call_Concluder::create_call_data(Call *call, System *sys, Config con void Call_Concluder::conclude_call(Call *call, System *sys, Config config) { Call_Data_t call_info = create_call_data(call, sys, config); + std::string loghdr = log_header( call_info.short_name, call_info.call_num, call_info.talkgroup_display , call_info.freq); if(call->get_state() == MONITORING && call->get_monitoring_state() == SUPERSEDED){ - BOOST_LOG_TRIVIAL(info) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\tFreq: " << format_freq(call_info.freq) << "\tCall has been superseded. Removing files."; + BOOST_LOG_TRIVIAL(info) << loghdr << "\tCall has been superseded. Removing files."; remove_call_files(call_info); return; } else 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: " << call_info.talkgroup_display << "\t Freq: " << format_freq(call_info.freq) << "\tNo Transmissions were recorded!"; + BOOST_LOG_TRIVIAL(error) << loghdr << "\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: " << call_info.talkgroup_display << "\t Freq: " << format_freq(call_info.freq) << "\tNo Transmissions were recorded! " << call_info.min_transmissions_removed << " tranmissions less than " << sys->get_min_tx_duration() << " seconds were removed."; + BOOST_LOG_TRIVIAL(info) << loghdr << "\tNo Transmissions were recorded! " << call_info.min_transmissions_removed << " tranmissions less than " << sys->get_min_tx_duration() << " seconds were removed."; return; } if (call_info.length <= sys->get_min_duration()) { - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m\tTG: " << call_info.talkgroup_display << "\t Freq: " << format_freq(call_info.freq) << "\t Call length: " << call_info.length << " is less than min duration: " << sys->get_min_duration(); + BOOST_LOG_TRIVIAL(error) << loghdr << "\t Call length: " << call_info.length << " is less than min duration: " << sys->get_min_duration(); remove_call_files(call_info); return; } @@ -440,20 +443,21 @@ void Call_Concluder::manage_call_data_workers() { if (it->wait_for(std::chrono::seconds(0)) == std::future_status::ready) { Call_Data_t call_info = it->get(); - + if (call_info.status == RETRY) { call_info.retry_attempt++; time_t start_time = call_info.start_time; + std::string loghdr = log_header( call_info.short_name, call_info.call_num, call_info.talkgroup_display , call_info.freq); if (call_info.retry_attempt > Call_Concluder::MAX_RETRY) { remove_call_files(call_info); - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m Failed to conclude call - TG: " << call_info.talkgroup_display << "\t" << std::put_time(std::localtime(&start_time), "%c %Z"); + BOOST_LOG_TRIVIAL(error) << loghdr << " Failed to conclude call - TG: " << call_info.talkgroup_display << "\t" << std::put_time(std::localtime(&start_time), "%c %Z"); } else { long jitter = rand() % 10; long backoff = (2 ^ call_info.retry_attempt * 60) + jitter; call_info.process_call_time = time(0) + backoff; retry_call_list.push_back(call_info); - BOOST_LOG_TRIVIAL(error) << "[" << call_info.short_name << "]\t\033[0;34m" << call_info.call_num << "C\033[0m \tTG: " << call_info.talkgroup_display << "\t" << std::put_time(std::localtime(&start_time), "%c %Z") << " retry attempt " << call_info.retry_attempt << " in " << backoff << "s\t retry queue: " << retry_call_list.size() << " calls"; + BOOST_LOG_TRIVIAL(error) << loghdr << " \tTG: " << call_info.talkgroup_display << "\t" << std::put_time(std::localtime(&start_time), "%c %Z") << " retry attempt " << call_info.retry_attempt << " in " << backoff << "s\t retry queue: " << retry_call_list.size() << " calls"; } } it = call_data_workers.erase(it); diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index 962986965..e81f7e0e1 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -111,7 +111,8 @@ void Call_impl::stop_call() { // If the call is being recorded, check to see if the recorder is currently in an INACTIVE state. This means that the recorder is not // doing anything and can be stopped. if ((state == RECORDING) && this->get_recorder()->is_idle()) { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\tStopping Recorded Call_impl - Last Update: " << this->since_last_update() << "s"; + std::string loghdr = log_header( sys->get_short_name(), this->get_call_num(), this->get_talkgroup_display(), this->get_freq()); + BOOST_LOG_TRIVIAL(info) << loghdr << "\tStopping Recorded Call_impl - Last Update: " << this->since_last_update() << "s"; } } } @@ -140,13 +141,15 @@ void Call_impl::conclude_call() { } else { this->set_signal(this->get_recorder()->get_pwr()); } - - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tRecorder last write:" << recorder->since_last_write() << "\tCall Elapsed: " << this->elapsed() << "\t Signal: " << floor(this->get_signal()) << "dBm\t Noise: " << floor(this->get_noise()) << "dBm"; + std::string loghdr = log_header( sys->get_short_name(), this->get_call_num(), this->get_talkgroup_display(), this->get_freq()); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tRecorder last write:" << recorder->since_last_write() << "\tCall Elapsed: " << this->elapsed() << "\t Signal: " << floor(this->get_signal()) << "dBm\t Noise: " << floor(this->get_noise()) << "dBm"; } else { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tRecorder last write:" << recorder->since_last_write() << "\tCall Elapsed: " << this->elapsed(); + std::string loghdr = log_header( sys->get_short_name(), this->get_call_num(), this->get_talkgroup_display(), this->get_freq()); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tRecorder last write:" << recorder->since_last_write() << "\tCall Elapsed: " << this->elapsed(); } if (was_update) { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mCall was UPDATE not GRANT\u001b[0m"; + std::string loghdr = log_header( sys->get_short_name(), this->get_call_num(), this->get_talkgroup_display(), this->get_freq()); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[33mCall was UPDATE not GRANT\u001b[0m"; } freq_error = this->get_recorder()->get_freq_error(); this->get_recorder()->stop(); @@ -181,7 +184,6 @@ Recorder *Call_impl::get_debug_recorder() { void Call_impl::set_recorder(Recorder *r) { recorder = r; - // BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(this->get_freq()) << "\t\u001b[32mStarting Recorder on Src: " << recorder->get_source()->get_device() << "\u001b[0m"; } Recorder *Call_impl::get_recorder() { @@ -377,7 +379,8 @@ bool Call_impl::add_source(long src) { bool Call_impl::update(TrunkMessage message) { last_update = time(NULL); if ((message.freq != this->curr_freq) || (message.talkgroup != this->talkgroup)) { - BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tCall_impl Update, message mismatch - Call_impl TG: " << get_talkgroup() << "\t Call_impl Freq: " << get_freq() << "\tMsg Tg: " << message.talkgroup << "\tMsg Freq: " << message.freq; + std::string loghdr = log_header( sys->get_short_name(), this->get_call_num(), this->get_talkgroup_display(), this->get_freq()); + BOOST_LOG_TRIVIAL(error) << loghdr << "C\033[0m\tCall_impl Update, message mismatch - \ttMsg Tg: " << message.talkgroup << "\tMsg Freq: " << message.freq; } else { return add_source(message.source); } diff --git a/trunk-recorder/formatter.cc b/trunk-recorder/formatter.cc index e8790844b..ddd166dd6 100644 --- a/trunk-recorder/formatter.cc +++ b/trunk-recorder/formatter.cc @@ -90,3 +90,10 @@ std::string format_state(State state, MonitoringState monitoringState) { } return boost::lexical_cast(state); } + +std::string log_header(std::string short_name,long call_num, std::string talkgroup_display, double freq) { + std::stringstream ss; + ss << "[" << short_name << "]\t\033[0;34m" << call_num << "C\033[0m\tTG: " << talkgroup_display << "\tFreq: " << format_freq(freq) << "\t\u001b[36m"; + std::string s = ss.str(); + return s; +} \ No newline at end of file diff --git a/trunk-recorder/formatter.h b/trunk-recorder/formatter.h index b718c0bec..323c9b506 100644 --- a/trunk-recorder/formatter.h +++ b/trunk-recorder/formatter.h @@ -11,6 +11,7 @@ extern boost::format format_time(float f); extern std::string format_state(State state); extern std::string format_state(State state, MonitoringState monitoringState); std::string get_frequency_format(); +extern std::string log_header(std::string short_name,long call_num, std::string talkgroup_display, double freq); extern int frequency_format; extern bool statusAsString; diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 9981ff7c3..183e32b9a 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -140,8 +140,8 @@ bool transmission_sink::start_recording(Call *call) { // when a wav_sink first gets associated with a call, set its lifecycle to idle; state = IDLE; /* Should reset more variables here */ - - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting wavfile sink SRC ID: " << curr_src_id << " Conventional: " << d_conventional; + std::string loghdr = log_header(d_current_call_short_name,d_current_call_num,d_current_call_talkgroup_display,d_current_call_freq); + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tStarting wavfile sink SRC ID: " << curr_src_id << " Conventional: " << d_conventional; return true; } @@ -202,16 +202,17 @@ bool transmission_sink::open_internal(const char *filename) { } void transmission_sink::set_source(long src) { + std::string loghdr = log_header(d_current_call_short_name,d_current_call_num,d_current_call_talkgroup_display,d_current_call_freq); if (curr_src_id == -1) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tUnit ID set via Control Channel, ext: " << src << "\tcurrent: " << curr_src_id << "\t samples: " << d_sample_count; + BOOST_LOG_TRIVIAL(info) << loghdr << "\tUnit ID set via Control Channel, ext: " << src << "\tcurrent: " << curr_src_id << "\t samples: " << d_sample_count; curr_src_id = src; } else if (d_conventional && (src != curr_src_id)) { if ((state == RECORDING) && (d_sample_count > 0)) { gr::thread::scoped_lock guard(d_mutex); - BOOST_LOG_TRIVIAL(error) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tUnit ID externally set, ext: " << src << "\tcurrent: " << curr_src_id << "\t samples: " << d_sample_count; + BOOST_LOG_TRIVIAL(error) << loghdr << "\tUnit ID externally set, ext: " << src << "\tcurrent: " << curr_src_id << "\t samples: " << d_sample_count; end_transmission(); state = IDLE; curr_src_id = src; @@ -290,7 +291,8 @@ State transmission_sink::get_state() { int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { gr::thread::scoped_lock guard(d_mutex); // hold mutex for duration of this function - + std::string loghdr = log_header(d_current_call_short_name,d_current_call_num,d_current_call_talkgroup_display,d_current_call_freq); + // it is possible that we could get part of a transmission after a call has stopped. We shouldn't do any recording if this happens.... this could mean that we miss part of the recording though if (!d_current_call) { time_t now = time(NULL); @@ -299,9 +301,9 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // It is possible the P25 Frame Assembler passes a TDU after the call has timed out. // In this case, the termination tag will be transferred on a blank sample and can safely be ignored. if (noutput_items == 1) { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tDropping " << noutput_items << " samples - current_call is null\t Rec State: " << format_state(this->state) << "\tSince close: " << its_been; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tDropping " << noutput_items << " samples - current_call is null\t Rec State: " << format_state(this->state) << "\tSince close: " << its_been; } else { - BOOST_LOG_TRIVIAL(error) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tDropping " << noutput_items << " samples - current_call is null\t Rec State: " << format_state(this->state) << "\tSince close: " << its_been; + BOOST_LOG_TRIVIAL(error) << loghdr << "\tDropping " << noutput_items << " samples - current_call is null\t Rec State: " << format_state(this->state) << "\tSince close: " << its_been; } return noutput_items; @@ -311,7 +313,7 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ if ((state == STOPPED) || (state == AVAILABLE)) { if (noutput_items > 1) { - BOOST_LOG_TRIVIAL(error) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tDropping " << noutput_items << " samples - Recorder state is: " << format_state(this->state); + BOOST_LOG_TRIVIAL(error) << loghdr << "\tDropping " << noutput_items << " samples - Recorder state is: " << format_state(this->state); // BOOST_LOG_TRIVIAL(info) << "WAV - state is: " << format_state(this->state) << "\t Dropping samples: " << noutput_items << " Since close: " << its_been << std::endl; } @@ -339,14 +341,14 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ if ((state == RECORDING) || (state == IDLE)) { if (d_current_call_talkgroup_encoded != grp_id) { if (!d_conventional) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tGROUP MISMATCH - Recorder TG: " << d_current_call_talkgroup_encoded << " Received TG: " << grp_id << " Recorder state: " << format_state(state) << " incoming: " << noutput_items; + BOOST_LOG_TRIVIAL(info) << loghdr << "\tGROUP MISMATCH - Recorder TG: " << d_current_call_talkgroup_encoded << " Received TG: " << grp_id << " Recorder state: " << format_state(state) << " incoming: " << noutput_items; if (d_sample_count > 0) { - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tEnding Transmission and IGNORING Rest - count: " << d_sample_count; + BOOST_LOG_TRIVIAL(info) << loghdr << "\tEnding Transmission and IGNORING Rest - count: " << d_sample_count; end_transmission(); } state = IGNORE; } else { - BOOST_LOG_TRIVIAL(debug) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tGroup Mismatch - Recorder Received TG: " << grp_id << " Recorder state: " << format_state(state) << " incoming samples: " << noutput_items; + BOOST_LOG_TRIVIAL(debug) << loghdr << "\tGroup Mismatch - Recorder Received TG: " << grp_id << " Recorder state: " << format_state(state) << " incoming samples: " << noutput_items; } } } @@ -395,12 +397,12 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ if (pmt::eq(spike_count_key, tags[i].key)) { d_spike_count = pmt::to_long(tags[i].value); - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tSpike Count: " << d_spike_count << " pos: " << pos << " offset: " << tags[i].offset; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tSpike Count: " << d_spike_count << " pos: " << pos << " offset: " << tags[i].offset; } if (pmt::eq(error_count_key, tags[i].key)) { d_error_count = pmt::to_long(tags[i].value); - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tError Count: " << d_error_count << " pos: " << pos << " offset: " << tags[i].offset; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tError Count: " << d_error_count << " pos: " << pos << " offset: " << tags[i].offset; } } } @@ -443,6 +445,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu int16_t sample_buf_s; int nwritten = 0; bool terminate_after_write = false; + std::string loghdr = log_header(d_current_call_short_name,d_current_call_num,d_current_call_talkgroup_display,d_current_call_freq); if (state == STOPPED) { return noutput_items; @@ -460,7 +463,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu } if (state == IGNORE) { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tResetting state from IGNORE to IDLE: " << noutput_items; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tResetting state from IGNORE to IDLE: " << noutput_items; state = IDLE; return noutput_items; @@ -468,26 +471,26 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu // The TDU can come in with voice samples. Write the voice samples and then end the transmission. if (d_sample_count > 0 && noutput_items > 1) { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTerminator received with items. Ending transmission after writing. Sample Count: " << d_sample_count << " Noutput Items: " << noutput_items; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tTerminator received with items. Ending transmission after writing. Sample Count: " << d_sample_count << " Noutput Items: " << noutput_items; terminate_after_write = true; // Handle the case of a terminator coming in without voice samples. End the transmission immediately. } else if (d_sample_count > 0) { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTerminator received without items. Ending transmission immediately. " << d_sample_count << " Noutput Items: " << noutput_items; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tTerminator received without items. Ending transmission immediately. " << d_sample_count << " Noutput Items: " << noutput_items; end_transmission(); return noutput_items; } else { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tTERM - skipped.... - count: " << d_sample_count; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tTERM - skipped.... - count: " << d_sample_count; return noutput_items; } } if (state == IGNORE) { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tIGNORE missing count: " << noutput_items; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tIGNORE missing count: " << noutput_items; return noutput_items; } if (state == IDLE) { - // BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tIDLE but haven't seen Group ID yet, missing count: " << noutput_items; + // BOOST_LOG_TRIVIAL(info) << loghdr << "\tIDLE but haven't seen Group ID yet, missing count: " << noutput_items; // return noutput_items; if (d_fp) { // if we are already recording a file for this call, close it before starting a new one. @@ -510,7 +513,7 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu return noutput_items; } - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting new Transmission \tSrc ID: " << curr_src_id; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\tStarting new Transmission \tSrc ID: " << curr_src_id; // curr_src_id = d_current_call->get_current_source_id(); state = RECORDING; @@ -549,9 +552,9 @@ int transmission_sink::dowork(int noutput_items, gr_vector_const_void_star &inpu d_last_write_time = std::chrono::steady_clock::now(); if (nwritten < noutput_items) { - BOOST_LOG_TRIVIAL(error) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tFailed to Write! Wrote: " << nwritten << " of " << noutput_items; + BOOST_LOG_TRIVIAL(error) << loghdr << "\tFailed to Write! Wrote: " << nwritten << " of " << noutput_items; } else { - BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\t Wrote: " << nwritten << " of " << noutput_items; + BOOST_LOG_TRIVIAL(trace) << loghdr << "\t Wrote: " << nwritten << " of " << noutput_items; } return noutput_items; } diff --git a/trunk-recorder/monitor_systems.cc b/trunk-recorder/monitor_systems.cc index 798807589..3b09ef1f7 100644 --- a/trunk-recorder/monitor_systems.cc +++ b/trunk-recorder/monitor_systems.cc @@ -26,7 +26,8 @@ bool start_recorder(Call *call, TrunkMessage message, Config &config, System *sy call->set_state(MONITORING); call->set_monitoring_state(UNKNOWN_TG); if (sys->get_hideUnknown() == false) { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[33mNot Recording: TG not in Talkgroup File\u001b[0m "; + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[33mNot Recording: TG not in Talkgroup File\u001b[0m "; } return false; } @@ -46,7 +47,8 @@ bool start_recorder(Call *call, TrunkMessage message, Config &config, System *sy if (tag != "") { tag = " (\033[0;34m" + tag + "\033[0m)"; } - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; + std::string loghdr = log_header( sys->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[31mNot Recording: ENCRYPTED\u001b[0m - src: " << unit_id << tag; } return false; } @@ -75,7 +77,8 @@ bool start_recorder(Call *call, TrunkMessage message, Config &config, System *sy recorder = source->get_digital_recorder(talkgroup, priority, call); } } else { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\tTG not in Talkgroup File "; + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); + BOOST_LOG_TRIVIAL(info) << loghdr << "\tTG not in Talkgroup File "; // A talkgroup was not found from the talkgroup file. // Use an analog recorder if this is a Type II trunk and defaultMode is analog. @@ -144,7 +147,8 @@ bool start_recorder(Call *call, TrunkMessage message, Config &config, System *sy if (!source_found) { call->set_state(MONITORING); call->set_monitoring_state(NO_SOURCE); - BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); + BOOST_LOG_TRIVIAL(error) << loghdr << "\t\u001b[36mNot Recording: no source covering Freq\u001b[0m"; return false; } return false; @@ -156,15 +160,15 @@ void print_status(std::vector &sources, std::vector &systems for (vector::iterator it = calls.begin(); it != calls.end(); it++) { Call *call = *it; Recorder *recorder = call->get_recorder(); - + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); if (call->get_state() == MONITORING) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m TG: " << call->get_talkgroup_display() << " Freq: " << format_freq(call->get_freq()) << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state(), call->get_monitoring_state()); + BOOST_LOG_TRIVIAL(info) << loghdr << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state(), call->get_monitoring_state()); } else { if (call->is_conventional() ) { bool is_enabled = call->get_recorder()->is_enabled(); - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m TG: " << call->get_talkgroup_display() << " Freq: " << format_freq(call->get_freq()) << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state()) << " Enabled: " << is_enabled; + BOOST_LOG_TRIVIAL(info) << loghdr << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state()) << " Enabled: " << is_enabled; } else { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m TG: " << call->get_talkgroup_display() << " Freq: " << format_freq(call->get_freq()) << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state()); + BOOST_LOG_TRIVIAL(info) << loghdr << " Elapsed: " << std::setw(4) << call->elapsed() << " State: " << format_state(call->get_state()); } } @@ -203,6 +207,7 @@ void manage_conventional_call(Call *call, Config &config) { // if any recording has happened if (call->get_current_length() > 0) { + BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m Call Length: " << call->get_current_length() << "s\t Idle: " << call->get_recorder()->is_idle() << "\t Squelched: " << call->get_recorder()->is_squelched() << " Idle Count: " << call->get_idle_count(); // means that the squelch is on and it has stopped recording @@ -277,7 +282,8 @@ void manage_calls(Config &config, std::vector &calls) { // - there hasn't been an UPDATE for it on the Control Channel in X seconds AND the recorder hasn't written anything in X seconds if ((recorder->since_last_write() > config.call_timeout) && (call->since_last_update() > config.call_timeout)) { - BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); + BOOST_LOG_TRIVIAL(trace) << loghdr << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); call->conclude_call(); // The State of the Recorders has changed, so lets send an update ended_call = true; @@ -290,8 +296,8 @@ void manage_calls(Config &config, std::vector &calls) { } } else if (call->since_last_update() > config.call_timeout) { Recorder *recorder = call->get_recorder(); - - BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Call UPDATEs has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); + BOOST_LOG_TRIVIAL(trace) << loghdr << "\t\u001b[36m Call UPDATEs has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); } ++it; } // foreach loggers @@ -447,7 +453,8 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message, Co if (recorder != NULL) { recorder_state = format_state(recorder->get_state()); } - BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mShould be Stopping RECORDING call, Recorder State: " << recorder_state << " RX overlapping TG message Freq, TG:" << message.talkgroup << "\u001b[0m"; + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); + BOOST_LOG_TRIVIAL(trace) << loghdr << "\t\u001b[36mShould be Stopping RECORDING call, Recorder State: " << recorder_state << " RX overlapping TG message Freq, TG:" << message.talkgroup << "\u001b[0m"; } it++; @@ -476,9 +483,10 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message, Co grant_call_data = boost::format("\u001b[34m%sC\u001b[0m %s/%s ") % call->get_call_num() % sys->get_multiSiteSystemName() % sys->get_multiSiteSystemNumber(); } } - + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); if (superseding_grant) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << original_call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mSuperseding Grant\u001b[0m - Stopping original call: " << original_call_data << "- Superseding call: " << grant_call_data; + + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[36mSuperseding Grant\u001b[0m - Stopping original call: " << original_call_data << "- Superseding call: " << grant_call_data; // Attempt to start a new call on the preferred NAC. recording_started = start_recorder(call, message, config, sys, sources); @@ -488,16 +496,17 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message, Co original_call->set_monitoring_state(SUPERSEDED); original_call->conclude_call(); } else { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << original_call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mCould not start Superseding recorder.\u001b[0m Continuing original call: " << original_call->get_call_num() << "C"; + + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[36mCould not start Superseding recorder.\u001b[0m Continuing original call: " << original_call->get_call_num() << "C"; } } else if (duplicate_grant) { call->set_state(MONITORING); call->set_monitoring_state(DUPLICATE); - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << original_call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mDuplicate Grant\u001b[0m - Not recording: " << grant_call_data << "- Original call: " << original_call_data; + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[36mDuplicate Grant\u001b[0m - Not recording: " << grant_call_data << "- Original call: " << original_call_data; } else { recording_started = start_recorder(call, message, config, sys, sources); if (recording_started && !grant_message) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE\u001b[0m"; + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[36mThis was an UPDATE\u001b[0m"; } } calls.push_back(call); diff --git a/trunk-recorder/recorders/analog_recorder.cc b/trunk-recorder/recorders/analog_recorder.cc index eb2b776c8..1bbf35b13 100644 --- a/trunk-recorder/recorders/analog_recorder.cc +++ b/trunk-recorder/recorders/analog_recorder.cc @@ -354,9 +354,8 @@ bool analog_recorder::start(Call *call) { talkgroup = call->get_talkgroup(); chan_freq = call->get_freq(); - - - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(chan_freq) << "\t\u001b[32mStarting Analog Recorder Num [" << rec_num << "]\u001b[0m \tSquelch: " << squelch_db; + std::string loghdr = log_header(call->get_short_name(),call->get_call_num(),this->call->get_talkgroup_display(),chan_freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[32mStarting Analog Recorder Num [" << rec_num << "]\u001b[0m \tSquelch: " << squelch_db; // BOOST_LOG_TRIVIAL(error) << "Setting squelch to: " << squelch_db << " block says: " << squelch->threshold(); levels->set_k(system->get_analog_levels()); diff --git a/trunk-recorder/recorders/dmr_recorder_impl.cc b/trunk-recorder/recorders/dmr_recorder_impl.cc index cbc322637..1b7f65807 100644 --- a/trunk-recorder/recorders/dmr_recorder_impl.cc +++ b/trunk-recorder/recorders/dmr_recorder_impl.cc @@ -234,8 +234,9 @@ void dmr_recorder_impl::stop() { if (state == ACTIVE) { recording_duration += wav_sink_slot0->total_length_in_seconds(); - - // BOOST_LOG_TRIVIAL(info) << "[" << this->call->get_short_name() << "]\t\033[0;34m" << this->call->get_call_num() << "C\033[0m\t- Stopping P25 Recorder Num [" << rec_num << "]\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(chan_freq) << " \tTDMA: " << d_phase2_tdma << "\tSlot: " << tdma_slot; + + //std::string loghdr = log_header(this->call->get_short_name(),this->call->get_call_num(),this->call->get_talkgroup_display(),chan_freq); + // BOOST_LOG_TRIVIAL(info) << loghdr << "Stopping P25 Recorder Num [" << rec_num << "]\tTDMA: " << d_phase2_tdma << "\tSlot: " << tdma_slot; state = INACTIVE; set_enabled(false); @@ -262,8 +263,8 @@ bool dmr_recorder_impl::start(Call *call) { short_name = call->get_short_name(); chan_freq = call->get_freq(); this->call = call; - - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(chan_freq) << "\t\u001b[32mStarting DMR Recorder Num [" << rec_num << "]\u001b[0m\tTDMA: " << call->get_phase2_tdma() << "\tSlot: " << call->get_tdma_slot(); + std::string loghdr = log_header(this->call->get_short_name(),this->call->get_call_num(),this->call->get_talkgroup_display(),chan_freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[32mStarting DMR Recorder Num [" << rec_num << "]\u001b[0m\tTDMA: " << call->get_phase2_tdma() << "\tSlot: " << call->get_tdma_slot(); int offset_amount = (center_freq - chan_freq); diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index dc007c60c..926946d9a 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -262,7 +262,8 @@ void p25_recorder_impl::stop() { recording_duration += fsk4_p25_decode->get_current_length(); } - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(chan_freq) << "\t\u001b[33mStopping P25 Recorder Num [" << rec_num << "]\u001b[0m\tTDMA: " << d_phase2_tdma << "\tSlot: " << tdma_slot << "\tHz Error: " << this->get_freq_error(); + std::string loghdr = log_header(this->call->get_short_name(),this->call->get_call_num(),this->call->get_talkgroup_display(),chan_freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[33mStopping P25 Recorder Num [" << rec_num << "]\u001b[0m\tTDMA: " << d_phase2_tdma << "\tSlot: " << tdma_slot << "\tHz Error: " << this->get_freq_error(); state = INACTIVE; set_enabled(false); @@ -317,7 +318,8 @@ bool p25_recorder_impl::start(Call *call) { chan_freq = call->get_freq(); this->call = call; - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(chan_freq) << "\t\u001b[32mStarting P25 Recorder Num [" << rec_num << "]\u001b[0m\tTDMA: " << call->get_phase2_tdma() << "\tSlot: " << call->get_tdma_slot() << "\tQPSK: " << qpsk_mod; + std::string loghdr = log_header(this->call->get_short_name(),this->call->get_call_num(),this->call->get_talkgroup_display(),chan_freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[32mStarting P25 Recorder Num [" << rec_num << "]\u001b[0m\tTDMA: " << call->get_phase2_tdma() << "\tSlot: " << call->get_tdma_slot() << "\tQPSK: " << qpsk_mod; int offset_amount = (center_freq - chan_freq); diff --git a/trunk-recorder/recorders/sigmf_recorder_impl.cc b/trunk-recorder/recorders/sigmf_recorder_impl.cc index f413b598c..065b02187 100644 --- a/trunk-recorder/recorders/sigmf_recorder_impl.cc +++ b/trunk-recorder/recorders/sigmf_recorder_impl.cc @@ -118,7 +118,8 @@ State sigmf_recorder_impl::get_state() { void sigmf_recorder_impl::stop() { if (state == ACTIVE) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(freq) << "\t\u001b[32mStopping SigMF Recorder Num [" << rec_num << "]\u001b[0m"; + std::string loghdr = log_header(this->call->get_short_name(),this->call->get_call_num(),this->call->get_talkgroup_display(),freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[32mStopping SigMF Recorder Num [" << rec_num << "]\u001b[0m"; state = INACTIVE; set_enabled(false); @@ -143,7 +144,8 @@ bool sigmf_recorder_impl::start(Call *call) { prefilter->tune_offset(offset_amount); //freq_xlat->set_center_freq(-offset_amount); - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << this->call->get_talkgroup_display() << "\tFreq: " << format_freq(freq) << "\t\u001b[32mStarting SigMF Recorder Num [" << rec_num << "]\u001b[0m"; + std::string loghdr = log_header(this->call->get_short_name(),this->call->get_call_num(),this->call->get_talkgroup_display(),freq); + BOOST_LOG_TRIVIAL(info) << loghdr << "\t\u001b[32mStarting SigMF Recorder Num [" << rec_num << "]\u001b[0m"; std::stringstream path_stream; diff --git a/trunk-recorder/source.cc b/trunk-recorder/source.cc index 40a7ffc4e..50dc98456 100644 --- a/trunk-recorder/source.cc +++ b/trunk-recorder/source.cc @@ -554,18 +554,18 @@ void Source::create_debug_recorder(gr::top_block_sptr tb, int source_num) { Recorder *Source::get_analog_recorder(Talkgroup *talkgroup, int priority, Call *call) { int num_available_recorders = get_num_available_analog_recorders(); - + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); if (talkgroup && (priority == -1)) { call->set_state(MONITORING); call->set_monitoring_state(IGNORED_TG); - BOOST_LOG_TRIVIAL(info) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\tNot recording talkgroup. Priority is -1."; + BOOST_LOG_TRIVIAL(info) << loghdr << "\tNot recording talkgroup. Priority is -1."; return NULL; } if (talkgroup && priority > num_available_recorders) { // a high priority is bad. You need at least the number of availalbe recorders to your priority call->set_state(MONITORING); call->set_monitoring_state(NO_RECORDER); - BOOST_LOG_TRIVIAL(error) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\tNot recording talkgroup. Priority is " << priority << " but only " << num_available_recorders << " recorders are available."; + BOOST_LOG_TRIVIAL(error) << loghdr << "\tNot recording talkgroup. Priority is " << priority << " but only " << num_available_recorders << " recorders are available."; return NULL; } @@ -583,24 +583,26 @@ Recorder *Source::get_analog_recorder(Call *call) { break; } } - BOOST_LOG_TRIVIAL(error) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t[ " << device << " ] No Analog Recorders Available."; + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); + BOOST_LOG_TRIVIAL(error) << loghdr << "\t[ " << device << " ] No Analog Recorders Available."; return NULL; } Recorder *Source::get_digital_recorder(Talkgroup *talkgroup, int priority, Call *call) { int num_available_recorders = get_num_available_digital_recorders(); + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); if (talkgroup && (priority == -1)) { call->set_state(MONITORING); call->set_monitoring_state(IGNORED_TG); - BOOST_LOG_TRIVIAL(info) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\tNot recording talkgroup. Priority is -1."; + BOOST_LOG_TRIVIAL(info) << loghdr << "\tNot recording talkgroup. Priority is -1."; return NULL; } if (talkgroup && priority > num_available_recorders) { // a high priority is bad. You need at least the number of availalbe recorders to your priority call->set_state(MONITORING); call->set_monitoring_state(NO_RECORDER); - BOOST_LOG_TRIVIAL(error) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\tNot recording talkgroup. Priority is " << priority << " but only " << num_available_recorders << " recorders are available."; + BOOST_LOG_TRIVIAL(error) << loghdr << "\tNot recording talkgroup. Priority is " << priority << " but only " << num_available_recorders << " recorders are available."; return NULL; } @@ -618,8 +620,8 @@ Recorder *Source::get_digital_recorder(Call *call) { break; } } - - BOOST_LOG_TRIVIAL(error) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t[ " << device << " ] No Digital Recorders Available."; + std::string loghdr = log_header( call->get_short_name(), call->get_call_num(), call->get_talkgroup_display(), call->get_freq()); + BOOST_LOG_TRIVIAL(error) << loghdr << "\t[ " << device << " ] No Digital Recorders Available."; for (std::vector::iterator it = digital_recorders.begin(); it != digital_recorders.end(); it++) {