Skip to content

Commit

Permalink
Merge pull request #20 from lachesis/clean_up_logging1
Browse files Browse the repository at this point in the history
Clean up logging with BOOST_LOG_TRIVIAL
  • Loading branch information
robotastic committed Aug 24, 2015
2 parents 7c2b8e2 + 3a4f256 commit e6287fe
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 90 deletions.
4 changes: 2 additions & 2 deletions debug_recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void debug_recorder::tune_offset(double f) {
prefilter->set_center_freq(offset_amount); // have to flip this for 3.7
}
void debug_recorder::deactivate() {
BOOST_LOG_TRIVIAL(info) << "debug_recorder.cc: Deactivating Logger [ " << num << " ] - freq[ " << freq << "] \t talkgroup[ " << talkgroup << " ] " << std::endl;
BOOST_LOG_TRIVIAL(info) << "debug_recorder.cc: Deactivating Logger [ " << num << " ] - freq[ " << freq << "] \t talkgroup[ " << talkgroup << " ]";


raw_sink->close();
Expand All @@ -118,7 +118,7 @@ void debug_recorder::activate( long t, double f, int n) {
freq = f;

tm *ltm = localtime(&starttime);
BOOST_LOG_TRIVIAL(info) << "debug_recorder.cc: Activating Logger [ " << num << " ] - freq[ " << freq << "] \t talkgroup[ " << talkgroup << " ] " <<std::endl;
BOOST_LOG_TRIVIAL(info) << "debug_recorder.cc: Activating Logger [ " << num << " ] - freq[ " << freq << "] \t talkgroup[ " << talkgroup << " ]";


prefilter->set_center_freq(f - center); // have to flip for 3.7
Expand Down
4 changes: 2 additions & 2 deletions dsd_recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void dsd_recorder::tune_offset(double f) {
prefilter->set_center_freq(offset_amount); // have to flip this for 3.7
}
void dsd_recorder::deactivate() {
BOOST_LOG_TRIVIAL(info) << "dsd_recorder.cc: Deactivating Logger [ " << num << " ] - freq[ " << freq << "] \t talkgroup[ " << talkgroup << " ] " << std::endl;
BOOST_LOG_TRIVIAL(info) << "dsd_recorder.cc: Deactivating Logger [ " << num << " ] - freq[ " << freq << "] \t talkgroup[ " << talkgroup << " ]";

//lock();

Expand Down Expand Up @@ -179,7 +179,7 @@ void dsd_recorder::activate( long t, double f, int n) {
freq = f;

tm *ltm = localtime(&starttime);
BOOST_LOG_TRIVIAL(info) << "dsd_recorder.cc: Activating Logger [ " << num << " ] - freq[ " << freq << "] \t talkgroup[ " << talkgroup << " ] " <<std::endl;
BOOST_LOG_TRIVIAL(info) << "dsd_recorder.cc: Activating Logger [ " << num << " ] - freq[ " << freq << "] \t talkgroup[ " << talkgroup << " ]";


prefilter->set_center_freq(f - center); // have to flip for 3.7
Expand Down
56 changes: 28 additions & 28 deletions main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ void load_config()
std::string driver = node.second.get<std::string>("driver","");
std::string device = node.second.get<std::string>("device","");

BOOST_LOG_TRIVIAL(info) << "Center: " << node.second.get<double>("center",0) << std::endl;
BOOST_LOG_TRIVIAL(info) << "Rate: " << node.second.get<double>("rate",0) << std::endl;
BOOST_LOG_TRIVIAL(info) << "Error: " << node.second.get<double>("error",0) << std::endl;
BOOST_LOG_TRIVIAL(info) << "Gain: " << node.second.get<int>("gain",0) << std::endl;
BOOST_LOG_TRIVIAL(info) << "IF Gain: " << node.second.get<int>("ifGain",0) << std::endl;
BOOST_LOG_TRIVIAL(info) << "BB Gain: " << node.second.get<int>("bbGain",0) << std::endl;
BOOST_LOG_TRIVIAL(info) << "Center: " << node.second.get<double>("center",0);
BOOST_LOG_TRIVIAL(info) << "Rate: " << node.second.get<double>("rate",0);
BOOST_LOG_TRIVIAL(info) << "Error: " << node.second.get<double>("error",0);
BOOST_LOG_TRIVIAL(info) << "Gain: " << node.second.get<int>("gain",0);
BOOST_LOG_TRIVIAL(info) << "IF Gain: " << node.second.get<int>("ifGain",0);
BOOST_LOG_TRIVIAL(info) << "BB Gain: " << node.second.get<int>("bbGain",0);

BOOST_LOG_TRIVIAL(info) << "Digital Recorders: " << node.second.get<int>("digitalRecorders",0) << std::endl;
BOOST_LOG_TRIVIAL(info) << "Debug Recorders: " << node.second.get<int>("debugRecorders",0) << std::endl;
BOOST_LOG_TRIVIAL(info) << "Analog Recorders: " << node.second.get<int>("analogRecorders",0) << std::endl;
BOOST_LOG_TRIVIAL(info) << "driver: " << node.second.get<std::string>("driver","") << std::endl;
BOOST_LOG_TRIVIAL(info) << "Digital Recorders: " << node.second.get<int>("digitalRecorders",0);
BOOST_LOG_TRIVIAL(info) << "Debug Recorders: " << node.second.get<int>("debugRecorders",0);
BOOST_LOG_TRIVIAL(info) << "Analog Recorders: " << node.second.get<int>("analogRecorders",0);
BOOST_LOG_TRIVIAL(info) << "driver: " << node.second.get<std::string>("driver","");


Source *source = new Source(center,rate,error,driver,device);
BOOST_LOG_TRIVIAL(info) << "Max HZ: " << source->get_max_hz() << std::endl;
BOOST_LOG_TRIVIAL(info) << "Min HZ: " << source->get_min_hz() << std::endl;
BOOST_LOG_TRIVIAL(info) << "Max HZ: " << source->get_max_hz();
BOOST_LOG_TRIVIAL(info) << "Min HZ: " << source->get_min_hz();
source->set_if_gain(if_gain);
source->set_bb_gain(bb_gain);
source->set_gain(gain);
Expand All @@ -176,16 +176,16 @@ void load_config()
control_channels.push_back(control_channel);
BOOST_LOG_TRIVIAL(info) << node.second.get<double>("",0) << " ";
}
BOOST_LOG_TRIVIAL(info) << std::endl;
BOOST_LOG_TRIVIAL(info);

talkgroups_file = pt.get<std::string>("talkgroupsFile","");
BOOST_LOG_TRIVIAL(info) << "Talkgroups File: " << talkgroups_file << std::endl;
BOOST_LOG_TRIVIAL(info) << "Talkgroups File: " << talkgroups_file;
system_type = pt.get<std::string>("system.type");

}
catch (std::exception const& e)
{
BOOST_LOG_TRIVIAL(error) << e.what() << std::endl;
BOOST_LOG_TRIVIAL(error) << e.what();
}

}
Expand All @@ -206,7 +206,7 @@ void start_recorder(TrunkMessage message) {


if (message.encrypted == false) {
//BOOST_LOG_TRIVIAL(error) << "\tCall created for: " << call->get_talkgroup() << "\tTDMA: " << call->get_tdma() << "\tEncrypted: " << call->get_encrypted() << std::endl;
//BOOST_LOG_TRIVIAL(error) << "\tCall created for: " << call->get_talkgroup() << "\tTDMA: " << call->get_tdma() << "\tEncrypted: " << call->get_encrypted();

for(vector<Source *>::iterator it = sources.begin(); it != sources.end(); it++) {
Source * source = *it;
Expand All @@ -215,7 +215,7 @@ void start_recorder(TrunkMessage message) {
source_found = true;

if (call->get_tdma()) {
BOOST_LOG_TRIVIAL(error) << "\tTrying to record TDMA: " << message.freq << " For TG: " << message.talkgroup << std::endl;
BOOST_LOG_TRIVIAL(error) << "\tTrying to record TDMA: " << message.freq << " For TG: " << message.talkgroup;
}

if (talkgroup)
Expand All @@ -226,7 +226,7 @@ void start_recorder(TrunkMessage message) {
recorder = source->get_digital_recorder(talkgroup->get_priority());
}
} else {
BOOST_LOG_TRIVIAL(error) << "\tTalkgroup not found: " << message.freq << " For TG: " << message.talkgroup << std::endl;
BOOST_LOG_TRIVIAL(error) << "\tTalkgroup not found: " << message.freq << " For TG: " << message.talkgroup;

recorder = source->get_digital_recorder(3);
}
Expand All @@ -235,7 +235,7 @@ void start_recorder(TrunkMessage message) {
call->set_recorder(recorder);
call->set_recording(true);
} else {
//BOOST_LOG_TRIVIAL(error) << "\tNot recording call" << std::endl;
BOOST_LOG_TRIVIAL(error) << "\tNot recording call";
}

debug_recorder = source->get_debug_recorder();
Expand All @@ -244,14 +244,14 @@ void start_recorder(TrunkMessage message) {
call->set_recorder(debug_recorder);
call->set_recording(true);
} else {
BOOST_LOG_TRIVIAL(trace) << "\tNot debug recording call" << std::endl;
BOOST_LOG_TRIVIAL(trace) << "\tNot debug recording call";
}

}

}
if (!source_found) {
BOOST_LOG_TRIVIAL(error) << "\tRecording not started because there was no source covering: " << message.freq << " For TG: " << message.talkgroup << std::endl;
BOOST_LOG_TRIVIAL(error) << "\tRecording not started because there was no source covering: " << message.freq << " For TG: " << message.talkgroup;
}
}

Expand All @@ -271,12 +271,12 @@ void stop_inactive_recorders() {
call->get_recorder()->deactivate();
system(shell_command);
//BOOST_LOG_TRIVIAL(info) << "\tRemoving TG: " << call->get_talkgroup() << "\tElapsed: " << call->elapsed() << std::endl;

}
if (call->get_debug_recording() == true) {
call->get_debug_recorder()->deactivate();
}

//BOOST_LOG_TRIVIAL(trace) << "\tRemoving TG: " << call->get_talkgroup() << "\tElapsed: " << call->elapsed();
it = calls.erase(it);
} else {
++it;
Expand All @@ -294,6 +294,7 @@ void assign_recorder(TrunkMessage message) {

if (call->get_talkgroup() == message.talkgroup) {
if (call->get_freq() != message.freq) {
BOOST_LOG_TRIVIAL(trace) << "\tRetune - Total calls: " << calls.size() << "\tTalkgroup: " << message.talkgroup << "\tOld Freq: " << call->get_freq() << "\tNew Freq: " << message.freq;
// not sure what to do here; looks like we should retune
if (call->get_recording() == true) {
BOOST_LOG_TRIVIAL(info) << "\tAssign Retune - Elapsed: " << call->elapsed() << "s \tSince update: " << call->since_last_update() << "s \tTalkgroup: " << message.talkgroup << "\tOld Freq: " << call->get_freq() << "\tNew Freq: " << message.freq << std::endl;
Expand All @@ -315,9 +316,8 @@ void assign_recorder(TrunkMessage message) {
if ((call->get_freq() == message.freq) && (call->get_tdma() == message.tdma)) {
//call_found = true;


if (call->get_recording() == true) {
BOOST_LOG_TRIVIAL(info) << "\tFreq in use - TG: " << message.talkgroup << "\tFreq: " << message.freq << "\tTDMA: " << message.tdma << "\t Ending Existing call\tTG: " << call->get_talkgroup() << "\tTMDA: " << call->get_tdma() << "\tElapsed: " << call->elapsed() << "s \tSince update: " << call->since_last_update() << std::endl;
BOOST_LOG_TRIVIAL(info) << "\tFreq in use - TG: " << message.talkgroup << "\tFreq: " << message.freq << "\tTDMA: " << message.tdma << "\t Ending Existing call\tTG: " << call->get_talkgroup() << "\tTMDA: " << call->get_tdma() << "\tElapsed: " << call->elapsed() << "s \tSince update: " << call->since_last_update();
//different talkgroups on the same freq, that is trouble

sprintf(shell_command,"./encode-upload.sh %s > /dev/null 2>&1 &", call->get_recorder()->get_filename());
Expand Down Expand Up @@ -375,7 +375,7 @@ void update_recorder(TrunkMessage message) {

if (call->get_talkgroup() == message.talkgroup) {
if (call->get_freq() != message.freq) {
//BOOST_LOG_TRIVIAL(trace) << "\tUpdate Retune - Total calls: " << calls.size() << "\tTalkgroup: " << message.talkgroup << "\tOld Freq: " << call->get_freq() << "\tNew Freq: " << message.freq;
// not sure what to do here; looks like we should retune

if (call->get_recording() == true) {
Expand Down Expand Up @@ -494,7 +494,7 @@ void monitor_messages() {
trunk_messages = p25_parser->parse_message(msg);
}
else {
BOOST_LOG_TRIVIAL(error) << msg->to_string() << std::endl;
BOOST_LOG_TRIVIAL(error) << msg->to_string();
}
handle_message(trunk_messages);

Expand All @@ -504,7 +504,7 @@ void monitor_messages() {
messagesDecodedSinceLastReport = 0;
lastMsgCountTime = currentTime;
if (msgs_decoded_per_second < 10 ) {
BOOST_LOG_TRIVIAL(error) << "\tControl Channel Message Decode Rate: " << msgs_decoded_per_second << "/sec" << std::endl;
BOOST_LOG_TRIVIAL(error) << "\tControl Channel Message Decode Rate: " << msgs_decoded_per_second << "/sec";
}
}

Expand Down Expand Up @@ -583,7 +583,7 @@ int main(void)
//------------------------------------------------------------------
//-- stop flow graph execution
//------------------------------------------------------------------
BOOST_LOG_TRIVIAL(info) << "stopping flow graph" << std::endl;
BOOST_LOG_TRIVIAL(info) << "stopping flow graph";
tb->stop();
tb->wait();
} else {
Expand Down
Loading

0 comments on commit e6287fe

Please sign in to comment.