Add primitive logging

master
Geoffrey Merck 4 years ago
parent 3757084529
commit 878ff18123

@ -26,6 +26,7 @@
#include "APRSWriter.h" #include "APRSWriter.h"
#include "DStarDefines.h" #include "DStarDefines.h"
#include "Defs.h" #include "Defs.h"
#include "Log.h"
CAPRSEntry::CAPRSEntry(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl) : CAPRSEntry::CAPRSEntry(const std::string& callsign, const std::string& band, double frequency, double offset, double range, double latitude, double longitude, double agl) :
m_callsign(callsign), m_callsign(callsign),
@ -204,7 +205,7 @@ void CAPRSWriter::writeHeader(const std::string& callsign, const CHeaderData& he
{ {
CAPRSEntry* entry = m_array[callsign]; CAPRSEntry* entry = m_array[callsign];
if (entry == NULL) { if (entry == NULL) {
wxLogError("Cannot find the callsign \"%s\" in the APRS array", callsign.c_str()); CLog::logError("Cannot find the callsign \"%s\" in the APRS array", callsign.c_str());
return; return;
} }
@ -222,7 +223,7 @@ void CAPRSWriter::writeData(const std::string& callsign, const CAMBEData& data)
CAPRSEntry* entry = m_array[callsign]; CAPRSEntry* entry = m_array[callsign];
if (entry == NULL) { if (entry == NULL) {
wxLogError("Cannot find the callsign \"%s\" in the APRS array", callsign.c_str()); CLog::logError("Cannot find the callsign \"%s\" in the APRS array", callsign.c_str());
return; return;
} }

@ -25,6 +25,7 @@
#include "DStarDefines.h" #include "DStarDefines.h"
#include "Utils.h" #include "Utils.h"
#include "Defs.h" #include "Defs.h"
#include "Log.h"
// #define DUMP_TX // #define DUMP_TX
@ -100,11 +101,11 @@ bool CAPRSWriterThread::start()
void* CAPRSWriterThread::Entry() void* CAPRSWriterThread::Entry()
{ {
printf("Starting the APRS Writer thread"); CLog::logInfo("Starting the APRS Writer thread");
m_connected = connect(); m_connected = connect();
if (!m_connected) { if (!m_connected) {
printf("Connect attempt to the APRS server has failed"); CLog::logInfo("Connect attempt to the APRS server has failed");
startReconnectionTimer(); startReconnectionTimer();
} }
@ -116,7 +117,7 @@ void* CAPRSWriterThread::Entry()
m_connected = connect(); m_connected = connect();
if (!m_connected) { if (!m_connected) {
printf("Reconnect attempt to the APRS server has failed"); CLog::logInfo("Reconnect attempt to the APRS server has failed");
startReconnectionTimer(); startReconnectionTimer();
} }
} }
@ -129,7 +130,7 @@ void* CAPRSWriterThread::Entry()
char* p = m_queue.getData(); char* p = m_queue.getData();
std::string text(p); std::string text(p);
printf("APRS ==> %s", text.c_str()); CLog::logInfo("APRS ==> %s", text.c_str());
::strcat(p, "\r\n"); ::strcat(p, "\r\n");
@ -137,7 +138,7 @@ void* CAPRSWriterThread::Entry()
if (!ret) { if (!ret) {
m_connected = false; m_connected = false;
m_socket.close(); m_socket.close();
printf("Connection to the APRS thread has failed"); CLog::logInfo("Connection to the APRS thread has failed");
startReconnectionTimer(); startReconnectionTimer();
} }
@ -148,19 +149,19 @@ void* CAPRSWriterThread::Entry()
int length = m_socket.readLine(line, APRS_TIMEOUT); int length = m_socket.readLine(line, APRS_TIMEOUT);
/*if (length == 0) /*if (length == 0)
wxLogWarning(wxT("No response from the APRS server after %u seconds"), APRS_TIMEOUT);*/ CLog::logWarning((wxT("No response from the APRS server after %u seconds"), APRS_TIMEOUT);*/
if (length < 0) { if (length < 0) {
m_connected = false; m_connected = false;
m_socket.close(); m_socket.close();
printf("Error when reading from the APRS server"); CLog::logInfo("Error when reading from the APRS server");
startReconnectionTimer(); startReconnectionTimer();
} }
if(length > 0 && line[0] != '#'//check if we have something and if that something is an APRS frame if(length > 0 && line[0] != '#'//check if we have something and if that something is an APRS frame
&& m_APRSReadCallback != NULL)//do we have someone wanting an APRS Frame? && m_APRSReadCallback != NULL)//do we have someone wanting an APRS Frame?
{ {
//printf("Received APRS Frame : ") + line); //CLog::logInfo("Received APRS Frame : ") + line);
m_APRSReadCallback(std::string(line)); m_APRSReadCallback(std::string(line));
} }
} }
@ -178,13 +179,13 @@ void* CAPRSWriterThread::Entry()
} }
catch (std::exception& e) { catch (std::exception& e) {
std::string message(e.what()); std::string message(e.what());
printf("Exception raised in the APRS Writer thread - \"%s\"", message.c_str()); CLog::logInfo("Exception raised in the APRS Writer thread - \"%s\"", message.c_str());
} }
catch (...) { catch (...) {
printf("Unknown exception raised in the APRS Writer thread"); CLog::logInfo("Unknown exception raised in the APRS Writer thread");
} }
printf("Stopping the APRS Writer thread"); CLog::logInfo("Stopping the APRS Writer thread");
return NULL; return NULL;
} }
@ -237,11 +238,11 @@ bool CAPRSWriterThread::connect()
std::string serverResponse(""); std::string serverResponse("");
length = m_socket.readLine(serverResponse, APRS_TIMEOUT); length = m_socket.readLine(serverResponse, APRS_TIMEOUT);
if (length == 0) { if (length == 0) {
printf("No reply from the APRS server after %u seconds", APRS_TIMEOUT); CLog::logInfo("No reply from the APRS server after %u seconds", APRS_TIMEOUT);
m_socket.close(); m_socket.close();
return false; return false;
} }
printf("Received login banner : %s", serverResponse.c_str()); CLog::logInfo("Received login banner : %s", serverResponse.c_str());
std::string filter(m_filter); std::string filter(m_filter);
if (filter.length() > 0) filter = " filter " + filter; if (filter.length() > 0) filter = " filter " + filter;
@ -250,7 +251,7 @@ bool CAPRSWriterThread::connect()
<< " pass " << m_password << " pass " << m_password
<< " vers " << (m_clientName.length() ? m_clientName : "ircDDBGateway") << " vers " << (m_clientName.length() ? m_clientName : "ircDDBGateway")
<< filter; << filter;
//printf("Connect String : ") + connectString); //CLog::logInfo("Connect String : ") + connectString);
ret = m_socket.writeLine(connectString.str()); ret = m_socket.writeLine(connectString.str());
if (!ret) { if (!ret) {
m_socket.close(); m_socket.close();
@ -259,19 +260,19 @@ bool CAPRSWriterThread::connect()
length = m_socket.readLine(serverResponse, APRS_TIMEOUT); length = m_socket.readLine(serverResponse, APRS_TIMEOUT);
if (length == 0) { if (length == 0) {
printf("No reply from the APRS server after %u seconds", APRS_TIMEOUT); CLog::logInfo("No reply from the APRS server after %u seconds", APRS_TIMEOUT);
m_socket.close(); m_socket.close();
return false; return false;
} }
if (length < 0) { if (length < 0) {
printf("Error when reading from the APRS server"); CLog::logInfo("Error when reading from the APRS server");
m_socket.close(); m_socket.close();
return false; return false;
} }
printf("Response from APRS server: %s", serverResponse.c_str()); CLog::logInfo("Response from APRS server: %s", serverResponse.c_str());
printf("Connected to the APRS server"); CLog::logInfo("Connected to the APRS server");
return true; return true;
} }

@ -25,6 +25,7 @@
#include "HeaderData.h" #include "HeaderData.h"
#include "AnnouncementUnit.h" #include "AnnouncementUnit.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
CAnnouncementUnit::CAnnouncementUnit(IRepeaterCallback* handler, const std::string& callsign, const std::string& fileName, const std::string& name) : CAnnouncementUnit::CAnnouncementUnit(IRepeaterCallback* handler, const std::string& callsign, const std::string& fileName, const std::string& name) :
m_handler(handler), m_handler(handler),
@ -41,7 +42,7 @@ m_id(0U)
m_name.resize(SHORT_CALLSIGN_LENGTH, ' '); m_name.resize(SHORT_CALLSIGN_LENGTH, ' ');
printf("Connected '%s' to %s using file - %s\n", name.c_str(), callsign.c_str(), fileName.c_str()); CLog::logInfo("Connected '%s' to %s using file - %s\n", name.c_str(), callsign.c_str(), fileName.c_str());
} }
CAnnouncementUnit::~CAnnouncementUnit() CAnnouncementUnit::~CAnnouncementUnit()

@ -28,6 +28,7 @@
#include "HeaderData.h" #include "HeaderData.h"
#include "AudioUnit.h" #include "AudioUnit.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
unsigned char* CAudioUnit::m_ambe = NULL; unsigned char* CAudioUnit::m_ambe = NULL;
unsigned int CAudioUnit::m_ambeLength = 0U; unsigned int CAudioUnit::m_ambeLength = 0U;
@ -247,7 +248,7 @@ bool CAudioUnit::lookup(unsigned int id, const std::string &name)
{ {
CIndexRecord* info = m_index[name]; CIndexRecord* info = m_index[name];
if (info == NULL) { if (info == NULL) {
// wxLogError(wxT("Cannot find the AMBE index for *%s*"), name.c_str()); // CLog::logError(wxT("Cannot find the AMBE index for *%s*"), name.c_str());
return false; return false;
} }
@ -335,12 +336,12 @@ bool CAudioUnit::readAMBE(const std::string& name)
struct stat sbuf; struct stat sbuf;
if (stat(fileName.c_str(), &sbuf)) { if (stat(fileName.c_str(), &sbuf)) {
printf("File %s not readable\n", fileName.c_str()); CLog::logInfo("File %s not readable\n", fileName.c_str());
fileName.assign(CFG_DIR); fileName.assign(CFG_DIR);
fileName.append("/data/"); fileName.append("/data/");
fileName += name; fileName += name;
if (stat(fileName.c_str(), &sbuf)) { if (stat(fileName.c_str(), &sbuf)) {
printf("File %s not readable\n", fileName.c_str()); CLog::logInfo("File %s not readable\n", fileName.c_str());
return false; return false;
} }
} }
@ -348,23 +349,23 @@ bool CAudioUnit::readAMBE(const std::string& name)
FILE *file = fopen(fileName.c_str(), "rb"); FILE *file = fopen(fileName.c_str(), "rb");
if (NULL == file) { if (NULL == file) {
printf("Cannot open %s for reading\n", fileName.c_str()); CLog::logInfo("Cannot open %s for reading\n", fileName.c_str());
return false; return false;
} }
printf("Reading %s\n", fileName.c_str()); CLog::logInfo("Reading %s\n", fileName.c_str());
unsigned char buffer[VOICE_FRAME_LENGTH_BYTES]; unsigned char buffer[VOICE_FRAME_LENGTH_BYTES];
size_t n = fread(buffer, 4, 1, file); size_t n = fread(buffer, 4, 1, file);
if (n != 4) { if (n != 4) {
printf("Unable to read the header from %s\n", fileName.c_str()); CLog::logInfo("Unable to read the header from %s\n", fileName.c_str());
fclose(file); fclose(file);
return false; return false;
} }
if (memcmp(buffer, "AMBE", 4)) { if (memcmp(buffer, "AMBE", 4)) {
printf("Invalid header from %s\n", fileName.c_str()); CLog::logInfo("Invalid header from %s\n", fileName.c_str());
fclose(file); fclose(file);
return false; return false;
} }
@ -383,7 +384,7 @@ bool CAudioUnit::readAMBE(const std::string& name)
n = fread(p, length, 1, file); n = fread(p, length, 1, file);
if (n != length) { if (n != length) {
printf("Unable to read the AMBE data from %s\n", fileName.c_str()); CLog::logInfo("Unable to read the AMBE data from %s\n", fileName.c_str());
fclose(file); fclose(file);
delete[] m_ambe; delete[] m_ambe;
m_ambe = NULL; m_ambe = NULL;
@ -402,26 +403,26 @@ bool CAudioUnit::readIndex(const std::string& name)
struct stat sbuf; struct stat sbuf;
if (stat(fileName.c_str(), &sbuf)) { if (stat(fileName.c_str(), &sbuf)) {
printf("File %s not readable\n", fileName.c_str()); CLog::logInfo("File %s not readable\n", fileName.c_str());
fileName.assign(CFG_DIR); fileName.assign(CFG_DIR);
fileName.append("/data/"); fileName.append("/data/");
fileName += name; fileName += name;
if (stat(fileName.c_str(), &sbuf)) { if (stat(fileName.c_str(), &sbuf)) {
printf("File %s not readable\n", fileName.c_str()); CLog::logInfo("File %s not readable\n", fileName.c_str());
return false; return false;
} }
} }
FILE *file = fopen(fileName.c_str(), "r"); FILE *file = fopen(fileName.c_str(), "r");
if (NULL == file) { if (NULL == file) {
printf("Cannot open %s for reading\n", fileName.c_str()); CLog::logInfo("Cannot open %s for reading\n", fileName.c_str());
return false; return false;
} }
// Add a silence entry at the beginning // Add a silence entry at the beginning
m_index[" "] = new CIndexRecord(" ", 0, SILENCE_LENGTH); m_index[" "] = new CIndexRecord(" ", 0, SILENCE_LENGTH);
printf("Reading %s\n", fileName.c_str()); CLog::logInfo("Reading %s\n", fileName.c_str());
char line[128]; char line[128];
while (fgets(line, 128, file)) { while (fgets(line, 128, file)) {
@ -437,7 +438,7 @@ bool CAudioUnit::readIndex(const std::string& name)
unsigned long length = std::stoul(leng); unsigned long length = std::stoul(leng);
if (start >= m_ambeLength || (start + length) >= m_ambeLength) if (start >= m_ambeLength || (start + length) >= m_ambeLength)
printf("The start or end for *%s* is out of range, start: %lu, end: %lu\n", name.c_str(), start, start + length); CLog::logInfo("The start or end for *%s* is out of range, start: %lu, end: %lu\n", name.c_str(), start, start + length);
else else
m_index[name] = new CIndexRecord(name, start + SILENCE_LENGTH, length); m_index[name] = new CIndexRecord(name, start + SILENCE_LENGTH, length);
} }

@ -27,6 +27,7 @@
#include "DStarDefines.h" #include "DStarDefines.h"
#include "Version.h" #include "Version.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
const char *HTML = "<table border=\"0\" width=\"95%%\"><tr><td width=\"4%%\"><img border=\"0\" src=%s></td><td width=\"96%%\"><font size=\"2\"><b>%s</b> DStarGateway %s</font></td></tr></table>"; const char *HTML = "<table border=\"0\" width=\"95%%\"><tr><td width=\"4%%\"><img border=\"0\" src=%s></td><td width=\"96%%\"><font size=\"2\"><b>%s</b> DStarGateway %s</font></td></tr></table>";
@ -256,7 +257,7 @@ bool CConnectData::setDPlusData(const unsigned char* data, unsigned int length,
case 8U: { case 8U: {
std::string reply((const char*)(data + 4U), 4U); std::string reply((const char*)(data + 4U), 4U);
printf("D-Plus reply is %.4s\n", reply.c_str()); CLog::logInfo("D-Plus reply is %.4s\n", reply.c_str());
if (::memcmp(data + 4U, "OKRW", 4U) == 0) if (::memcmp(data + 4U, "OKRW", 4U) == 0)
m_type = CT_ACK; m_type = CT_ACK;

@ -240,7 +240,7 @@ void CDCSHandler::process(CPollData& poll)
} }
} }
wxLogMessage("Unknown incoming DCS poll from %s", reflector.c_str()); CLog::logInfo("Unknown incoming DCS poll from %s", reflector.c_str());
} }
void CDCSHandler::process(CConnectData& connect) void CDCSHandler::process(CConnectData& connect)
@ -285,14 +285,14 @@ void CDCSHandler::process(CConnectData& connect)
// Check the validity of our repeater callsign // Check the validity of our repeater callsign
IReflectorCallback* handler = CRepeaterHandler::findDVRepeater(reflectorCallsign); IReflectorCallback* handler = CRepeaterHandler::findDVRepeater(reflectorCallsign);
if (handler == NULL) { if (handler == NULL) {
wxLogMessage("DCS connect to unknown reflector %s from %s", reflectorCallsign.c_str(), repeaterCallsign.c_str()); CLog::logInfo("DCS connect to unknown reflector %s from %s", reflectorCallsign.c_str(), repeaterCallsign.c_str());
CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, connect.getYourAddress(), connect.getYourPort()); CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, connect.getYourAddress(), connect.getYourPort());
m_incoming->writeConnect(reply); m_incoming->writeConnect(reply);
return; return;
} }
// A new connect packet indicates the need for a new entry // A new connect packet indicates the need for a new entry
wxLogMessage("New incoming DCS link to %s from %s", reflectorCallsign.c_str(), repeaterCallsign.c_str()); CLog::logInfo("New incoming DCS link to %s from %s", reflectorCallsign.c_str(), repeaterCallsign.c_str());
CDCSHandler* dcs = new CDCSHandler(handler, repeaterCallsign, reflectorCallsign, m_incoming, yourAddress, yourPort, DIR_INCOMING); CDCSHandler* dcs = new CDCSHandler(handler, repeaterCallsign, reflectorCallsign, m_incoming, yourAddress, yourPort, DIR_INCOMING);
@ -312,7 +312,7 @@ void CDCSHandler::process(CConnectData& connect)
CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, yourAddress, yourPort); CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, yourAddress, yourPort);
m_incoming->writeConnect(reply); m_incoming->writeConnect(reply);
wxLogError("No space to add new DCS link, ignoring"); CLog::logError("No space to add new DCS link, ignoring");
delete dcs; delete dcs;
} }
} }
@ -346,7 +346,7 @@ void CDCSHandler::link(IReflectorCallback* handler, const std::string& repeater,
CConnectData reply(m_gatewayType, repeater, gateway, CT_LINK1, address, DCS_PORT); CConnectData reply(m_gatewayType, repeater, gateway, CT_LINK1, address, DCS_PORT);
protoHandler->writeConnect(reply); protoHandler->writeConnect(reply);
} else { } else {
wxLogError("No space to add new DCS link, ignoring"); CLog::logError("No space to add new DCS link, ignoring");
delete dcs; delete dcs;
} }
} }
@ -361,7 +361,7 @@ void CDCSHandler::unlink(IReflectorCallback* handler, const std::string& callsig
if (exclude) { if (exclude) {
if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination == handler && reflector->m_reflector != callsign) { if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination == handler && reflector->m_reflector != callsign) {
wxLogMessage("Removing outgoing DCS link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str()); CLog::logInfo("Removing outgoing DCS link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str());
if (reflector->m_linkState == DCS_LINKING || reflector->m_linkState == DCS_LINKED) { if (reflector->m_linkState == DCS_LINKING || reflector->m_linkState == DCS_LINKED) {
CConnectData connect(reflector->m_repeater, reflector->m_reflector, CT_UNLINK, reflector->m_yourAddress, reflector->m_yourPort); CConnectData connect(reflector->m_repeater, reflector->m_reflector, CT_UNLINK, reflector->m_yourAddress, reflector->m_yourPort);
@ -376,7 +376,7 @@ void CDCSHandler::unlink(IReflectorCallback* handler, const std::string& callsig
} }
} else { } else {
if (reflector->m_destination == handler && reflector->m_reflector == callsign) { if (reflector->m_destination == handler && reflector->m_reflector == callsign) {
wxLogMessage("Removing DCS link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str()); CLog::logInfo("Removing DCS link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str());
if (reflector->m_linkState == DCS_LINKING || reflector->m_linkState == DCS_LINKED) { if (reflector->m_linkState == DCS_LINKING || reflector->m_linkState == DCS_LINKED) {
CConnectData connect(reflector->m_repeater, reflector->m_reflector, CT_UNLINK, reflector->m_yourAddress, reflector->m_yourPort); CConnectData connect(reflector->m_repeater, reflector->m_reflector, CT_UNLINK, reflector->m_yourAddress, reflector->m_yourPort);
@ -420,7 +420,7 @@ void CDCSHandler::unlink()
if (reflector != NULL) { if (reflector != NULL) {
if (!reflector->m_repeater.empty()) { if (!reflector->m_repeater.empty()) {
wxLogMessage("Unlinking from DCS reflector %s", reflector->m_reflector.c_str()); CLog::logInfo("Unlinking from DCS reflector %s", reflector->m_reflector.c_str());
CConnectData connect(reflector->m_repeater, reflector->m_reflector, CT_UNLINK, reflector->m_yourAddress, reflector->m_yourPort); CConnectData connect(reflector->m_repeater, reflector->m_reflector, CT_UNLINK, reflector->m_yourAddress, reflector->m_yourPort);
reflector->m_handler->writeConnect(connect); reflector->m_handler->writeConnect(connect);
@ -460,10 +460,10 @@ void CDCSHandler::gatewayUpdate(const std::string& reflector, const std::string&
if (reflector->m_reflector.substr(0, LONG_CALLSIGN_LENGTH - 1U) == gateway) { if (reflector->m_reflector.substr(0, LONG_CALLSIGN_LENGTH - 1U) == gateway) {
if (!address.empty()) { if (!address.empty()) {
// A new address, change the value // A new address, change the value
wxLogMessage("Changing IP address of DCS gateway or reflector %s to %s", reflector->m_reflector.c_str(), address.c_str()); CLog::logInfo("Changing IP address of DCS gateway or reflector %s to %s", reflector->m_reflector.c_str(), address.c_str());
reflector->m_yourAddress.s_addr = ::inet_addr(address.c_str()); reflector->m_yourAddress.s_addr = ::inet_addr(address.c_str());
} else { } else {
wxLogMessage("IP address for DCS gateway or reflector %s has been removed", reflector->m_reflector.c_str()); CLog::logInfo("IP address for DCS gateway or reflector %s has been removed", reflector->m_reflector.c_str());
// No address, this probably shouldn't happen.... // No address, this probably shouldn't happen....
if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination != NULL) if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination != NULL)
@ -515,7 +515,7 @@ void CDCSHandler::processInt(CAMBEData& data)
if (m_whiteList != NULL) { if (m_whiteList != NULL) {
bool res = m_whiteList->isInList(my); bool res = m_whiteList->isInList(my);
if (!res) { if (!res) {
wxLogMessage("%s rejected from DCS as not found in the white list", my.c_str()); CLog::logInfo("%s rejected from DCS as not found in the white list", my.c_str());
m_dcsId = 0x00U; m_dcsId = 0x00U;
return; return;
} }
@ -524,7 +524,7 @@ void CDCSHandler::processInt(CAMBEData& data)
if (m_blackList != NULL) { if (m_blackList != NULL) {
bool res = m_blackList->isInList(my); bool res = m_blackList->isInList(my);
if (res) { if (res) {
wxLogMessage("%s rejected from DCS as found in the black list", my.c_str()); CLog::logInfo("%s rejected from DCS as found in the black list", my.c_str());
m_dcsId = 0x00U; m_dcsId = 0x00U;
return; return;
} }
@ -644,7 +644,7 @@ bool CDCSHandler::processInt(CConnectData& connect, CD_TYPE type)
return false; return false;
if (m_linkState == DCS_LINKING) { if (m_linkState == DCS_LINKING) {
wxLogMessage("DCS ACK message received from %s", GET_DISP_REFLECTOR(this).c_str()); CLog::logInfo("DCS ACK message received from %s", GET_DISP_REFLECTOR(this).c_str());
if (m_direction == DIR_OUTGOING && m_destination != NULL) if (m_direction == DIR_OUTGOING && m_destination != NULL)
m_destination->linkUp(DP_DCS, GET_DISP_REFLECTOR(this)); m_destination->linkUp(DP_DCS, GET_DISP_REFLECTOR(this));
@ -661,7 +661,7 @@ bool CDCSHandler::processInt(CConnectData& connect, CD_TYPE type)
return false; return false;
if (m_linkState == DCS_LINKING) { if (m_linkState == DCS_LINKING) {
wxLogMessage("DCS NAK message received from %s", GET_DISP_REFLECTOR(this).c_str()); CLog::logInfo("DCS NAK message received from %s", GET_DISP_REFLECTOR(this).c_str());
if (m_direction == DIR_OUTGOING && m_destination != NULL) if (m_direction == DIR_OUTGOING && m_destination != NULL)
m_destination->linkRefused(DP_DCS, GET_DISP_REFLECTOR(this)); m_destination->linkRefused(DP_DCS, GET_DISP_REFLECTOR(this));
@ -670,7 +670,7 @@ bool CDCSHandler::processInt(CConnectData& connect, CD_TYPE type)
} }
if (m_linkState == DCS_UNLINKING) { if (m_linkState == DCS_UNLINKING) {
wxLogMessage("DCS NAK message received from %s", GET_DISP_REFLECTOR(this).c_str()); CLog::logInfo("DCS NAK message received from %s", GET_DISP_REFLECTOR(this).c_str());
if (m_direction == DIR_OUTGOING && m_destination != NULL) if (m_direction == DIR_OUTGOING && m_destination != NULL)
m_destination->linkFailed(DP_DCS, m_reflector, false); m_destination->linkFailed(DP_DCS, m_reflector, false);
@ -685,7 +685,7 @@ bool CDCSHandler::processInt(CConnectData& connect, CD_TYPE type)
return false; return false;
if (m_linkState == DCS_LINKED) { if (m_linkState == DCS_LINKED) {
wxLogMessage("DCS disconnect message received from %s", GET_DISP_REFLECTOR(this).c_str()); CLog::logInfo("DCS disconnect message received from %s", GET_DISP_REFLECTOR(this).c_str());
if (m_direction == DIR_OUTGOING && m_destination != NULL) if (m_direction == DIR_OUTGOING && m_destination != NULL)
m_destination->linkFailed(DP_DCS, GET_DISP_REFLECTOR(this), false); m_destination->linkFailed(DP_DCS, GET_DISP_REFLECTOR(this), false);
@ -716,13 +716,13 @@ bool CDCSHandler::clockInt(unsigned int ms)
switch (m_linkState) { switch (m_linkState) {
case DCS_LINKING: case DCS_LINKING:
wxLogMessage("DCS link to %s has failed to connect", GET_DISP_REFLECTOR(this).c_str()); CLog::logInfo("DCS link to %s has failed to connect", GET_DISP_REFLECTOR(this).c_str());
break; break;
case DCS_LINKED: case DCS_LINKED:
wxLogMessage("DCS link to %s has failed (poll inactivity)", GET_DISP_REFLECTOR(this).c_str()); CLog::logInfo("DCS link to %s has failed (poll inactivity)", GET_DISP_REFLECTOR(this).c_str());
break; break;
case DCS_UNLINKING: case DCS_UNLINKING:
wxLogMessage("DCS link to %s has failed to disconnect cleanly", GET_DISP_REFLECTOR(this).c_str()); CLog::logInfo("DCS link to %s has failed to disconnect cleanly", GET_DISP_REFLECTOR(this).c_str());
break; break;
default: default:
break; break;

@ -22,6 +22,7 @@
#include "DCSProtocolHandlerPool.h" #include "DCSProtocolHandlerPool.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
CDCSProtocolHandlerPool::CDCSProtocolHandlerPool(const unsigned int port, const std::string &addr) : CDCSProtocolHandlerPool::CDCSProtocolHandlerPool(const unsigned int port, const std::string &addr) :
m_basePort(port), m_basePort(port),
@ -29,7 +30,7 @@ m_address(addr)
{ {
assert(port > 0U); assert(port > 0U);
m_index = m_pool.end(); m_index = m_pool.end();
printf("DCS UDP port base = %u\n", port); CLog::logInfo("DCS UDP port base = %u\n", port);
} }
CDCSProtocolHandlerPool::~CDCSProtocolHandlerPool() CDCSProtocolHandlerPool::~CDCSProtocolHandlerPool()
@ -59,14 +60,14 @@ CDCSProtocolHandler *CDCSProtocolHandlerPool::getHandler(unsigned int port)
if (proto) { if (proto) {
if (proto->open()) { if (proto->open()) {
m_pool[port] = proto; m_pool[port] = proto;
printf("New CDCSProtocolHandler now on port %u.\n", port); CLog::logInfo("New CDCSProtocolHandler now on port %u.\n", port);
} else { } else {
delete proto; delete proto;
proto = NULL; proto = NULL;
printf("ERROR: Can't open new DCS UDP port %u!\n", port); CLog::logInfo("ERROR: Can't open new DCS UDP port %u!\n", port);
} }
} else } else
printf("ERROR: Can't allocate new CDCSProtocolHandler at port %u\n", port); CLog::logInfo("ERROR: Can't allocate new CDCSProtocolHandler at port %u\n", port);
return proto; return proto;
} }
@ -77,13 +78,13 @@ void CDCSProtocolHandlerPool::release(CDCSProtocolHandler *handler)
if (it->second == handler) { if (it->second == handler) {
it->second->close(); it->second->close();
delete it->second; delete it->second;
printf("Releasing CDCSProtocolHandler on port %u.\n", it->first); CLog::logInfo("Releasing CDCSProtocolHandler on port %u.\n", it->first);
m_pool.erase(it); m_pool.erase(it);
return; return;
} }
} }
// we should never get here! // we should never get here!
printf("ERROR: could not find CDCSProtocolHander (port=%u) to release!\n", handler->getPort()); CLog::logInfo("ERROR: could not find CDCSProtocolHander (port=%u) to release!\n", handler->getPort());
} }
DCS_TYPE CDCSProtocolHandlerPool::read() DCS_TYPE CDCSProtocolHandlerPool::read()

@ -110,7 +110,7 @@ void CDDHandler::initialise(unsigned int maxRoutes, const std::string& name)
#if defined(__linux__) #if defined(__linux__)
m_fd = ::open("/dev/net/tun", O_RDWR); m_fd = ::open("/dev/net/tun", O_RDWR);
if (m_fd < 0) { if (m_fd < 0) {
wxLogError("Cannot open /dev/net/tun"); CLog::logError("Cannot open /dev/net/tun");
return; return;
} }
@ -121,18 +121,18 @@ void CDDHandler::initialise(unsigned int maxRoutes, const std::string& name)
::strcpy(ifr1.ifr_name, "tap%d"); ::strcpy(ifr1.ifr_name, "tap%d");
if (::ioctl(m_fd, TUNSETIFF, (void *)&ifr1) < 0) { if (::ioctl(m_fd, TUNSETIFF, (void *)&ifr1) < 0) {
wxLogError("TUNSETIFF ioctl failed, closing the tap device"); CLog::logError("TUNSETIFF ioctl failed, closing the tap device");
::close(m_fd); ::close(m_fd);
m_fd = -1; m_fd = -1;
return; return;
} }
std::string device = std::string(ifr1.ifr_name); std::string device = std::string(ifr1.ifr_name);
wxLogMessage("DD mode Tap interface created on %s", device.c_str()); CLog::logInfo("DD mode Tap interface created on %s", device.c_str());
int fd = ::socket(AF_INET, SOCK_DGRAM, 0); int fd = ::socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) { if (fd < 0) {
wxLogError("Unable to open the config socket, closing the tap device"); CLog::logError("Unable to open the config socket, closing the tap device");
::close(m_fd); ::close(m_fd);
m_fd = -1; m_fd = -1;
return; return;
@ -144,7 +144,7 @@ void CDDHandler::initialise(unsigned int maxRoutes, const std::string& name)
ifr2.ifr_flags = IFF_UP | IFF_BROADCAST | IFF_MULTICAST; ifr2.ifr_flags = IFF_UP | IFF_BROADCAST | IFF_MULTICAST;
if (::ioctl(fd, SIOCSIFFLAGS, (void *)&ifr2) < 0) { if (::ioctl(fd, SIOCSIFFLAGS, (void *)&ifr2) < 0) {
wxLogError("SIOCSIFFLAGS ioctl failed, closing the tap device"); CLog::logError("SIOCSIFFLAGS ioctl failed, closing the tap device");
::close(m_fd); ::close(m_fd);
m_fd = -1; m_fd = -1;
return; return;
@ -219,7 +219,7 @@ void CDDHandler::process(CDDData& data)
} }
if (!found) { if (!found) {
wxLogMessage("Adding DD user %s with ethernet address %02X:%02X:%02X:%02X:%02X:%02X", myCall1.c_str(), CLog::logInfo("Adding DD user %s with ethernet address %02X:%02X:%02X:%02X:%02X:%02X", myCall1.c_str(),
address[0], address[1], address[2], address[3], address[4], address[5]); address[0], address[1], address[2], address[3], address[4], address[5]);
CEthernet* ethernet = new CEthernet(address, myCall1); CEthernet* ethernet = new CEthernet(address, myCall1);
@ -236,7 +236,7 @@ void CDDHandler::process(CDDData& data)
} }
if (!found) { if (!found) {
wxLogError("No space to add new DD ethernet address"); CLog::logError("No space to add new DD ethernet address");
delete ethernet; delete ethernet;
return; return;
} }
@ -247,7 +247,7 @@ void CDDHandler::process(CDDData& data)
ssize_t len = ::write(m_fd, (char*)m_buffer, length); ssize_t len = ::write(m_fd, (char*)m_buffer, length);
if (len != ssize_t(length)) if (len != ssize_t(length))
wxLogError("Error returned from write()"); CLog::logError("Error returned from write()");
#endif #endif
} }
@ -276,7 +276,7 @@ CDDData* CDDHandler::read()
int ret = ::select(m_fd + 1, &readFds, NULL, NULL, &tv); int ret = ::select(m_fd + 1, &readFds, NULL, NULL, &tv);
if (ret < 0) { if (ret < 0) {
wxLogError("Error returned from select()"); CLog::logError("Error returned from select()");
return NULL; return NULL;
} }
@ -293,7 +293,7 @@ CDDData* CDDHandler::read()
ssize_t len = ::read(m_fd, (char*)m_buffer, BUFFER_LENGTH); ssize_t len = ::read(m_fd, (char*)m_buffer, BUFFER_LENGTH);
if (len <= 0) { if (len <= 0) {
wxLogError("Error returned from read()"); CLog::logError("Error returned from read()");
return NULL; return NULL;
} }
@ -318,17 +318,17 @@ CDDData* CDDHandler::read()
} }
if (ethernet == NULL) { if (ethernet == NULL) {
wxLogWarning("Cannot find the ethernet address of %02X:%02X:%02X:%02X:%02X:%02X in the ethernet list", address[0], address[1], address[2], address[3], address[4], address[5]); CLog::logWarning("Cannot find the ethernet address of %02X:%02X:%02X:%02X:%02X:%02X in the ethernet list", address[0], address[1], address[2], address[3], address[4], address[5]);
return NULL; return NULL;
} }
CRepeaterHandler* handler = CRepeaterHandler::findDDRepeater(); CRepeaterHandler* handler = CRepeaterHandler::findDDRepeater();
if (handler == NULL) { if (handler == NULL) {
wxLogWarning("Incoming DD data to unknown repeater"); CLog::logWarning("Incoming DD data to unknown repeater");
return NULL; return NULL;
} }
// wxLogMessage("Mapping ethernet address %02X:%02X:%02X:%02X:%02X:%02X to user %s", // CLog::logInfo("Mapping ethernet address %02X:%02X:%02X:%02X:%02X:%02X to user %s",
// address[0], address[1], address[2], address[3], address[4], address[5], // address[0], address[1], address[2], address[3], address[4], address[5],
// ethernet->getCallsign().c_str()); // ethernet->getCallsign().c_str());
@ -377,7 +377,7 @@ void CDDHandler::writeStatus(const CEthernet& ethernet)
std::ofstream file; std::ofstream file;
file.open(fullName, std::ios::app); file.open(fullName, std::ios::app);
if (!file.is_open()) { if (!file.is_open()) {
wxLogError("Unable to open %s for writing", fullName.c_str()); CLog::logError("Unable to open %s for writing", fullName.c_str());
return; return;
} }

@ -298,7 +298,7 @@ void CDExtraHandler::process(const CPollData& poll)
return; return;
// An unmatched poll indicates the need for a new entry // An unmatched poll indicates the need for a new entry
wxLogMessage("New incoming DExtra Dongle from %s", reflector.c_str()); CLog::logInfo("New incoming DExtra Dongle from %s", reflector.c_str());
CDExtraHandler* handler = new CDExtraHandler(m_incoming, reflector, yourAddress, yourPort, DIR_INCOMING); CDExtraHandler* handler = new CDExtraHandler(m_incoming, reflector, yourAddress, yourPort, DIR_INCOMING);
@ -317,7 +317,7 @@ void CDExtraHandler::process(const CPollData& poll)
CPollData poll(m_callsign, yourAddress, yourPort); CPollData poll(m_callsign, yourAddress, yourPort);
m_incoming->writePoll(poll); m_incoming->writePoll(poll);
} else { } else {
wxLogError("No space to add new DExtra Dongle, ignoring"); CLog::logError("No space to add new DExtra Dongle, ignoring");
delete handler; delete handler;
} }
} }
@ -366,14 +366,14 @@ void CDExtraHandler::process(CConnectData& connect)
// Check the validity of our repeater callsign // Check the validity of our repeater callsign
IReflectorCallback* handler = CRepeaterHandler::findDVRepeater(reflectorCallsign); IReflectorCallback* handler = CRepeaterHandler::findDVRepeater(reflectorCallsign);
if (handler == NULL) { if (handler == NULL) {
wxLogMessage("DExtra connect to unknown reflector %s from %s", reflectorCallsign.c_str(), repeaterCallsign.c_str()); CLog::logInfo("DExtra connect to unknown reflector %s from %s", reflectorCallsign.c_str(), repeaterCallsign.c_str());
CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, yourAddress, yourPort); CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, yourAddress, yourPort);
m_incoming->writeConnect(reply); m_incoming->writeConnect(reply);
return; return;
} }
// A new connect packet indicates the need for a new entry // A new connect packet indicates the need for a new entry
wxLogMessage("New incoming DExtra link to %s from %s", reflectorCallsign.c_str(), repeaterCallsign.c_str()); CLog::logInfo("New incoming DExtra link to %s from %s", reflectorCallsign.c_str(), repeaterCallsign.c_str());
CDExtraHandler* dextra = new CDExtraHandler(handler, repeaterCallsign, reflectorCallsign, m_incoming, yourAddress, yourPort, DIR_INCOMING); CDExtraHandler* dextra = new CDExtraHandler(handler, repeaterCallsign, reflectorCallsign, m_incoming, yourAddress, yourPort, DIR_INCOMING);
@ -398,7 +398,7 @@ void CDExtraHandler::process(CConnectData& connect)
CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, yourAddress, yourPort); CConnectData reply(repeaterCallsign, reflectorCallsign, CT_NAK, yourAddress, yourPort);
m_incoming->writeConnect(reply); m_incoming->writeConnect(reply);
wxLogError("No space to add new DExtra repeater, ignoring"); CLog::logError("No space to add new DExtra repeater, ignoring");
delete dextra; delete dextra;
} }
} }
@ -425,7 +425,7 @@ void CDExtraHandler::link(IReflectorCallback* handler, const std::string& repeat
CConnectData reply(repeater, gateway, CT_LINK1, address, DEXTRA_PORT); CConnectData reply(repeater, gateway, CT_LINK1, address, DEXTRA_PORT);
protoHandler->writeConnect(reply); protoHandler->writeConnect(reply);
} else { } else {
wxLogError("No space to add new DExtra link, ignoring"); CLog::logError("No space to add new DExtra link, ignoring");
delete dextra; delete dextra;
} }
} }
@ -440,7 +440,7 @@ void CDExtraHandler::unlink(IReflectorCallback* handler, const std::string& call
if (exclude) { if (exclude) {
if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination == handler && reflector->m_reflector != callsign) { if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination == handler && reflector->m_reflector != callsign) {
wxLogMessage("Removing outgoing DExtra link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str()); CLog::logInfo("Removing outgoing DExtra link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str());
if (reflector->m_linkState == DEXTRA_LINKING || reflector->m_linkState == DEXTRA_LINKED) { if (reflector->m_linkState == DEXTRA_LINKING || reflector->m_linkState == DEXTRA_LINKED) {
CConnectData connect(reflector->m_repeater, reflector->m_yourAddress, reflector->m_yourPort); CConnectData connect(reflector->m_repeater, reflector->m_yourAddress, reflector->m_yourPort);
@ -455,7 +455,7 @@ void CDExtraHandler::unlink(IReflectorCallback* handler, const std::string& call
} }
} else { } else {
if (reflector->m_destination == handler && reflector->m_reflector == callsign) { if (reflector->m_destination == handler && reflector->m_reflector == callsign) {
wxLogMessage("Removing DExtra link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str()); CLog::logInfo("Removing DExtra link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str());
if (reflector->m_linkState == DEXTRA_LINKING || reflector->m_linkState == DEXTRA_LINKED) { if (reflector->m_linkState == DEXTRA_LINKING || reflector->m_linkState == DEXTRA_LINKED) {
CConnectData connect(reflector->m_repeater, reflector->m_yourAddress, reflector->m_yourPort); CConnectData connect(reflector->m_repeater, reflector->m_yourAddress, reflector->m_yourPort);
@ -502,7 +502,7 @@ void CDExtraHandler::unlink()
if (reflector != NULL) { if (reflector != NULL) {
if (!reflector->m_repeater.empty()) { if (!reflector->m_repeater.empty()) {
wxLogMessage("Unlinking from DExtra reflector %s", reflector->m_reflector.c_str()); CLog::logInfo("Unlinking from DExtra reflector %s", reflector->m_reflector.c_str());
CConnectData connect(reflector->m_repeater, reflector->m_yourAddress, reflector->m_yourPort); CConnectData connect(reflector->m_repeater, reflector->m_yourAddress, reflector->m_yourPort);
reflector->m_handler->writeConnect(connect); reflector->m_handler->writeConnect(connect);
@ -540,10 +540,10 @@ void CDExtraHandler::gatewayUpdate(const std::string& reflector, const std::stri
if (reflector->m_reflector.substr(0, LONG_CALLSIGN_LENGTH - 1U) == gateway) { if (reflector->m_reflector.substr(0, LONG_CALLSIGN_LENGTH - 1U) == gateway) {
if (!address.empty()) { if (!address.empty()) {
// A new address, change the value // A new address, change the value
wxLogMessage("Changing IP address of DExtra gateway or reflector %s to %s", reflector->m_reflector.c_str(), address.c_str()); CLog::logInfo("Changing IP address of DExtra gateway or reflector %s to %s", reflector->m_reflector.c_str(), address.c_str());
reflector->m_yourAddress.s_addr = ::inet_addr(address.c_str()); reflector->m_yourAddress.s_addr = ::inet_addr(address.c_str());
} else { } else {
wxLogMessage("IP address for DExtra gateway or reflector %s has been removed", reflector->m_reflector.c_str()); CLog::logInfo("IP address for DExtra gateway or reflector %s has been removed", reflector->m_reflector.c_str());
// No address, this probably shouldn't happen.... // No address, this probably shouldn't happen....
if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination != NULL) if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination != NULL)
@ -590,7 +590,7 @@ void CDExtraHandler::processInt(CHeaderData& header)
if (m_whiteList != NULL) { if (m_whiteList != NULL) {
bool res = m_whiteList->isInList(my); bool res = m_whiteList->isInList(my);
if (!res) { if (!res) {
wxLogMessage("%s rejected from DExtra as not found in the white list", my.c_str()); CLog::logInfo("%s rejected from DExtra as not found in the white list", my.c_str());
m_dExtraId = 0x00U; m_dExtraId = 0x00U;
return; return;
} }
@ -599,7 +599,7 @@ void CDExtraHandler::processInt(CHeaderData& header)
if (m_blackList != NULL) { if (m_blackList != NULL) {
bool res = m_blackList->isInList(my); bool res = m_blackList->isInList(my);
if (res) { if (res) {
wxLogMessage("%s rejected from DExtra as found in the black list", my.c_str()); CLog::logInfo("%s rejected from DExtra as found in the black list", my.c_str());
m_dExtraId = 0x00U; m_dExtraId = 0x00U;
return; return;
} }
@ -743,7 +743,7 @@ bool CDExtraHandler::processInt(CConnectData& connect, CD_TYPE type)
return false; return false;
if (m_linkState == DEXTRA_LINKING) { if (m_linkState == DEXTRA_LINKING) {
wxLogMessage("DExtra ACK message received from %s", m_reflector.c_str()); CLog::logInfo("DExtra ACK message received from %s", m_reflector.c_str());
if (m_direction == DIR_OUTGOING && m_destination != NULL) if (m_direction == DIR_OUTGOING && m_destination != NULL)
m_destination->linkUp(DP_DEXTRA, m_reflector); m_destination->linkUp(DP_DEXTRA, m_reflector);
@ -761,7 +761,7 @@ bool CDExtraHandler::processInt(CConnectData& connect, CD_TYPE type)
return false; return false;
if (m_linkState == DEXTRA_LINKING) { if (m_linkState == DEXTRA_LINKING) {
wxLogMessage("DExtra NAK message received from %s", m_reflector.c_str()); CLog::logInfo("DExtra NAK message received from %s", m_reflector.c_str());
if (m_direction == DIR_OUTGOING && m_destination != NULL) if (m_direction == DIR_OUTGOING && m_destination != NULL)
m_destination->linkRefused(DP_DEXTRA, m_reflector); m_destination->linkRefused(DP_DEXTRA, m_reflector);
@ -776,7 +776,7 @@ bool CDExtraHandler::processInt(CConnectData& connect, CD_TYPE type)
return false; return false;
if (m_linkState == DEXTRA_LINKED) { if (m_linkState == DEXTRA_LINKED) {
wxLogMessage("DExtra disconnect message received from %s", m_reflector.c_str()); CLog::logInfo("DExtra disconnect message received from %s", m_reflector.c_str());
if (m_direction == DIR_OUTGOING && m_destination != NULL) if (m_direction == DIR_OUTGOING && m_destination != NULL)
m_destination->linkFailed(DP_DEXTRA, m_reflector, false); m_destination->linkFailed(DP_DEXTRA, m_reflector, false);
@ -810,13 +810,13 @@ bool CDExtraHandler::clockInt(unsigned int ms)
switch (m_linkState) { switch (m_linkState) {
case DEXTRA_LINKING: case DEXTRA_LINKING:
wxLogMessage("DExtra link to %s has failed to connect", m_reflector.c_str()); CLog::logInfo("DExtra link to %s has failed to connect", m_reflector.c_str());
break; break;
case DEXTRA_LINKED: case DEXTRA_LINKED:
wxLogMessage("DExtra link to %s has failed (poll inactivity)", m_reflector.c_str()); CLog::logInfo("DExtra link to %s has failed (poll inactivity)", m_reflector.c_str());
break; break;
case DEXTRA_UNLINKING: case DEXTRA_UNLINKING:
wxLogMessage("DExtra link to %s has failed to disconnect cleanly", m_reflector.c_str()); CLog::logInfo("DExtra link to %s has failed to disconnect cleanly", m_reflector.c_str());
break; break;
default: default:
break; break;

@ -21,6 +21,7 @@
#include "DExtraProtocolHandlerPool.h" #include "DExtraProtocolHandlerPool.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
CDExtraProtocolHandlerPool::CDExtraProtocolHandlerPool(const unsigned int port, const std::string &addr) : CDExtraProtocolHandlerPool::CDExtraProtocolHandlerPool(const unsigned int port, const std::string &addr) :
m_basePort(port), m_basePort(port),
@ -28,7 +29,7 @@ m_address(addr)
{ {
assert(port > 0U); assert(port > 0U);
m_index = m_pool.end(); m_index = m_pool.end();
printf("DExtra UDP port base = %u\n", port); CLog::logInfo("DExtra UDP port base = %u\n", port);
} }
CDExtraProtocolHandlerPool::~CDExtraProtocolHandlerPool() CDExtraProtocolHandlerPool::~CDExtraProtocolHandlerPool()
@ -59,14 +60,14 @@ CDExtraProtocolHandler* CDExtraProtocolHandlerPool::getHandler(unsigned int port
if (proto) { if (proto) {
if (proto->open()) { if (proto->open()) {
m_pool[port] = proto; m_pool[port] = proto;
printf("New CDExtraProtocolHandler now on UDP port %u.\n", port); CLog::logInfo("New CDExtraProtocolHandler now on UDP port %u.\n", port);
} else { } else {
delete proto; delete proto;
proto = NULL; proto = NULL;
printf("ERROR: Can't open new DExtra UDP port %u!\n", port); CLog::logInfo("ERROR: Can't open new DExtra UDP port %u!\n", port);
} }
} else } else
printf("ERROR: Can't allocate new CDExtraProtocolHandler at port %u\n", port); CLog::logInfo("ERROR: Can't allocate new CDExtraProtocolHandler at port %u\n", port);
return proto; return proto;
} }
@ -77,13 +78,13 @@ void CDExtraProtocolHandlerPool::release(CDExtraProtocolHandler *handler)
if (it->second == handler) { if (it->second == handler) {
it->second->close(); it->second->close();
delete it->second; delete it->second;
printf("Releasing CDExtraProtocolHandler on port %u.\n", it->first); CLog::logInfo("Releasing CDExtraProtocolHandler on port %u.\n", it->first);
m_pool.erase(it); m_pool.erase(it);
return; return;
} }
} }
// we should never get here! // we should never get here!
printf("ERROR: could not find CDExtraProtocolHander (port=%u) to release!\n", handler->getPort()); CLog::logInfo("ERROR: could not find CDExtraProtocolHander (port=%u) to release!\n", handler->getPort());
} }
DEXTRA_TYPE CDExtraProtocolHandlerPool::read() DEXTRA_TYPE CDExtraProtocolHandlerPool::read()

@ -26,6 +26,7 @@
#include "DStarDefines.h" #include "DStarDefines.h"
#include "Utils.h" #include "Utils.h"
#include "Defs.h" #include "Defs.h"
#include "Log.h"
const std::string OPENDSTAR_HOSTNAME = "auth.dstargateway.org"; const std::string OPENDSTAR_HOSTNAME = "auth.dstargateway.org";
const unsigned int OPENDSTAR_PORT = 20001U; const unsigned int OPENDSTAR_PORT = 20001U;
@ -65,7 +66,7 @@ void CDPlusAuthenticator::start()
void* CDPlusAuthenticator::Entry() void* CDPlusAuthenticator::Entry()
{ {
printf("Starting the D-Plus Authenticator thread"); CLog::logInfo("Starting the D-Plus Authenticator thread");
authenticate(m_loginCallsign, OPENDSTAR_HOSTNAME, OPENDSTAR_PORT, '2', true); authenticate(m_loginCallsign, OPENDSTAR_HOSTNAME, OPENDSTAR_PORT, '2', true);
@ -85,13 +86,13 @@ void* CDPlusAuthenticator::Entry()
} }
catch (std::exception& e) { catch (std::exception& e) {
std::string message(e.what()); std::string message(e.what());
printf("Exception raised in the D-Plus Authenticator thread - \"%s\"", message.c_str()); CLog::logInfo("Exception raised in the D-Plus Authenticator thread - \"%s\"", message.c_str());
} }
catch (...) { catch (...) {
printf("Unknown exception raised in the D-Plus Authenticator thread"); CLog::logInfo("Unknown exception raised in the D-Plus Authenticator thread");
} }
printf("Stopping the D-Plus Authenticator thread"); CLog::logInfo("Stopping the D-Plus Authenticator thread");
return NULL; return NULL;
} }
@ -160,12 +161,12 @@ bool CDPlusAuthenticator::authenticate(const std::string& callsign, const std::s
// Ensure that we get exactly len - 2U bytes from the TCP stream // Ensure that we get exactly len - 2U bytes from the TCP stream
ret = read(socket, buffer + 2U, len - 2U); ret = read(socket, buffer + 2U, len - 2U);
if (!ret) { if (!ret) {
printf("Short read from %s:%u", hostname.c_str(), port); CLog::logInfo("Short read from %s:%u", hostname.c_str(), port);
break; break;
} }
if ((buffer[1U] & 0xC0U) != 0xC0U || buffer[2U] != 0x01U) { if ((buffer[1U] & 0xC0U) != 0xC0U || buffer[2U] != 0x01U) {
printf("Invalid packet received from %s:%u", hostname.c_str(), port); CLog::logInfo("Invalid packet received from %s:%u", hostname.c_str(), port);
CUtils::dump("Details:", buffer, len); CUtils::dump("Details:", buffer, len);
break; break;
} }
@ -183,7 +184,7 @@ bool CDPlusAuthenticator::authenticate(const std::string& callsign, const std::s
// An empty name or IP address or an inactive gateway/reflector is not written out // An empty name or IP address or an inactive gateway/reflector is not written out
if (address.length() > 0U && name.length() > 0U && !name.compare(0, 3, "XRF") == 0 && active && writeToCache){ if (address.length() > 0U && name.length() > 0U && !name.compare(0, 3, "XRF") == 0 && active && writeToCache){
if (name.compare(0, 3, "REF") == 0) if (name.compare(0, 3, "REF") == 0)
printf("D-Plus: %s\t%s", name.c_str(), address.c_str()); CLog::logInfo("D-Plus: %s\t%s", name.c_str(), address.c_str());
name += " "; name += " ";
name = name.substr(LONG_CALLSIGN_LENGTH - 1U); name = name.substr(LONG_CALLSIGN_LENGTH - 1U);
@ -195,7 +196,7 @@ bool CDPlusAuthenticator::authenticate(const std::string& callsign, const std::s
ret = read(socket, buffer + 0U, 2U); ret = read(socket, buffer + 0U, 2U);
} }
printf("Registered with %s using callsign %s", hostname.c_str(), callsign.c_str()); CLog::logInfo("Registered with %s using callsign %s", hostname.c_str(), callsign.c_str());
socket.close(); socket.close();

@ -279,7 +279,7 @@ void CDPlusHandler::process(const CPollData& poll)
} }
// If we cannot find an existing link, we ignore the poll // If we cannot find an existing link, we ignore the poll
wxLogMessage(("Incoming poll from unknown D-Plus dongle")); CLog::logInfo(("Incoming poll from unknown D-Plus dongle"));
} }
void CDPlusHandler::process(CConnectData& connect) void CDPlusHandler::process(CConnectData& connect)
@ -321,7 +321,7 @@ void CDPlusHandler::process(CConnectData& connect)
return; return;
if (type != CT_LINK1) { if (type != CT_LINK1) {
wxLogMessage(("Incoming D-Plus message from unknown source")); CLog::logInfo(("Incoming D-Plus message from unknown source"));
return; return;
} }
@ -352,7 +352,7 @@ void CDPlusHandler::process(CConnectData& connect)
CConnectData connect(CT_LINK1, yourAddress, yourPort); CConnectData connect(CT_LINK1, yourAddress, yourPort);
m_incoming->writeConnect(connect); m_incoming->writeConnect(connect);
} else { } else {
wxLogError("No space to add new D-Plus dongle, ignoring"); CLog::logError("No space to add new D-Plus dongle, ignoring");
delete dplus; delete dplus;
} }
} }
@ -380,7 +380,7 @@ void CDPlusHandler::link(IReflectorCallback* handler, const std::string& repeate
protoHandler->writeConnect(connect); protoHandler->writeConnect(connect);
m_stateChange = true; m_stateChange = true;
} else { } else {
wxLogError(("No space to add new D-Plus reflector, ignoring")); CLog::logError(("No space to add new D-Plus reflector, ignoring"));
delete dplus; delete dplus;
} }
} }
@ -410,7 +410,7 @@ void CDPlusHandler::unlink(IReflectorCallback* handler, const std::string& calls
if (exclude) { if (exclude) {
if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination == handler && reflector->m_reflector != callsign) { if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination == handler && reflector->m_reflector != callsign) {
wxLogMessage("Removing outgoing D-Plus link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str()); CLog::logInfo("Removing outgoing D-Plus link %s, %s", reflector->m_repeater.c_str(), reflector->m_reflector.c_str());
if (reflector->m_linkState == DPLUS_LINKING || reflector->m_linkState == DPLUS_LINKED) { if (reflector->m_linkState == DPLUS_LINKING || reflector->m_linkState == DPLUS_LINKED) {
CConnectData connect(CT_UNLINK, reflector->m_yourAddress, DPLUS_PORT); CConnectData connect(CT_UNLINK, reflector->m_yourAddress, DPLUS_PORT);
@ -428,7 +428,7 @@ void CDPlusHandler::unlink(IReflectorCallback* handler, const std::string& calls
} }
} else { } else {
if (reflector->m_destination == handler && reflector->m_reflector == callsign) { if (reflector->m_destination == handler && reflector->m_reflector == callsign) {
wxLogMessage(("Removing D-Plus link %s, %s"), reflector->m_repeater.c_str(), reflector->m_reflector.c_str()); CLog::logInfo(("Removing D-Plus link %s, %s"), reflector->m_repeater.c_str(), reflector->m_reflector.c_str());
if (reflector->m_linkState == DPLUS_LINKING || reflector->m_linkState == DPLUS_LINKED) { if (reflector->m_linkState == DPLUS_LINKING || reflector->m_linkState == DPLUS_LINKED) {
CConnectData connect(CT_UNLINK, reflector->m_yourAddress, DPLUS_PORT); CConnectData connect(CT_UNLINK, reflector->m_yourAddress, DPLUS_PORT);
@ -474,7 +474,7 @@ void CDPlusHandler::unlink()
CDPlusHandler* reflector = m_reflectors[i]; CDPlusHandler* reflector = m_reflectors[i];
if (reflector != NULL) { if (reflector != NULL) {
if (!reflector->m_reflector.empty()) if (!reflector->m_reflector.empty())
wxLogMessage(("Unlinking from D-Plus reflector or dongle %s"), reflector->m_reflector.c_str()); CLog::logInfo(("Unlinking from D-Plus reflector or dongle %s"), reflector->m_reflector.c_str());
CConnectData connect(CT_UNLINK, reflector->m_yourAddress, reflector->m_yourPort); CConnectData connect(CT_UNLINK, reflector->m_yourAddress, reflector->m_yourPort);
reflector->m_handler->writeConnect(connect); reflector->m_handler->writeConnect(connect);
@ -514,10 +514,10 @@ void CDPlusHandler::gatewayUpdate(const std::string& gateway, const std::string&
if (!reflector->m_reflector.empty() && reflector->m_reflector.substr(0, LONG_CALLSIGN_LENGTH - 1U) == gatewayBase) { if (!reflector->m_reflector.empty() && reflector->m_reflector.substr(0, LONG_CALLSIGN_LENGTH - 1U) == gatewayBase) {
if (!address.empty()) { if (!address.empty()) {
// A new address, change the value // A new address, change the value
wxLogMessage("Changing IP address of D-Plus gateway or reflector %s to %s", gatewayBase.c_str(), address.c_str()); CLog::logInfo("Changing IP address of D-Plus gateway or reflector %s to %s", gatewayBase.c_str(), address.c_str());
reflector->m_yourAddress.s_addr = ::inet_addr(address.c_str()); reflector->m_yourAddress.s_addr = ::inet_addr(address.c_str());
} else { } else {
wxLogMessage("IP address for D-Plus gateway or reflector %s has been removed", gatewayBase.c_str()); CLog::logInfo("IP address for D-Plus gateway or reflector %s has been removed", gatewayBase.c_str());
// No address, this probably shouldn't happen.... // No address, this probably shouldn't happen....
if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination != NULL) if (reflector->m_direction == DIR_OUTGOING && reflector->m_destination != NULL)
@ -567,7 +567,7 @@ void CDPlusHandler::processInt(CHeaderData& header)
if (m_whiteList != NULL) { if (m_whiteList != NULL) {
bool res = m_whiteList->isInList(my); bool res = m_whiteList->isInList(my);
if (!res) { if (!res) {
wxLogMessage(("%s rejected from D-Plus as not found in the white list"), my.c_str()); CLog::logInfo(("%s rejected from D-Plus as not found in the white list"), my.c_str());
m_dPlusId = 0x00U; m_dPlusId = 0x00U;
return; return;
} }
@ -576,7 +576,7 @@ void CDPlusHandler::processInt(CHeaderData& header)
if (m_blackList != NULL) { if (m_blackList != NULL) {
bool res = m_blackList->isInList(my); bool res = m_blackList->isInList(my);
if (res) { if (res) {
wxLogMessage(("%s rejected from D-Plus as found in the black list"), my.c_str()); CLog::logInfo(("%s rejected from D-Plus as found in the black list"), my.c_str());
m_dPlusId = 0x00U; m_dPlusId = 0x00U;
return; return;
} }
@ -679,7 +679,7 @@ bool CDPlusHandler::processInt(CConnectData& connect, CD_TYPE type)
switch (type) { switch (type) {
case CT_ACK: case CT_ACK:
if (m_linkState == DPLUS_LINKING) { if (m_linkState == DPLUS_LINKING) {
wxLogMessage(("D-Plus ACK message received from %s"), m_reflector.c_str()); CLog::logInfo(("D-Plus ACK message received from %s"), m_reflector.c_str());
m_destination->linkUp(DP_DPLUS, m_reflector); m_destination->linkUp(DP_DPLUS, m_reflector);
m_stateChange = true; m_stateChange = true;
m_linkState = DPLUS_LINKED; m_linkState = DPLUS_LINKED;
@ -691,7 +691,7 @@ bool CDPlusHandler::processInt(CConnectData& connect, CD_TYPE type)
case CT_NAK: case CT_NAK:
if (m_linkState == DPLUS_LINKING) { if (m_linkState == DPLUS_LINKING) {
wxLogMessage(("D-Plus NAK message received from %s"), m_reflector.c_str()); CLog::logInfo(("D-Plus NAK message received from %s"), m_reflector.c_str());
m_destination->linkRefused(DP_DPLUS, m_reflector); m_destination->linkRefused(DP_DPLUS, m_reflector);
CConnectData reply(CT_UNLINK, connect.getYourAddress(), connect.getYourPort()); CConnectData reply(CT_UNLINK, connect.getYourAddress(), connect.getYourPort());
m_handler->writeConnect(reply); m_handler->writeConnect(reply);
@ -701,7 +701,7 @@ bool CDPlusHandler::processInt(CConnectData& connect, CD_TYPE type)
case CT_UNLINK: case CT_UNLINK:
if (m_linkState == DPLUS_UNLINKING) { if (m_linkState == DPLUS_UNLINKING) {
wxLogMessage(("D-Plus disconnect acknowledgement received from %s"), m_reflector.c_str()); CLog::logInfo(("D-Plus disconnect acknowledgement received from %s"), m_reflector.c_str());
m_destination->linkFailed(DP_DPLUS, m_reflector, false); m_destination->linkFailed(DP_DPLUS, m_reflector, false);
m_stateChange = true; m_stateChange = true;
m_tryTimer.stop(); m_tryTimer.stop();
@ -724,7 +724,7 @@ bool CDPlusHandler::processInt(CConnectData& connect, CD_TYPE type)
switch (type) { switch (type) {
case CT_LINK2: { case CT_LINK2: {
m_reflector = connect.getRepeater(); m_reflector = connect.getRepeater();
wxLogMessage(("D-Plus dongle link to %s has started"), m_reflector.c_str()); CLog::logInfo(("D-Plus dongle link to %s has started"), m_reflector.c_str());
CConnectData reply(CT_ACK, m_yourAddress, m_yourPort); CConnectData reply(CT_ACK, m_yourAddress, m_yourPort);
m_handler->writeConnect(reply); m_handler->writeConnect(reply);
m_linkState = DPLUS_LINKED; m_linkState = DPLUS_LINKED;
@ -734,7 +734,7 @@ bool CDPlusHandler::processInt(CConnectData& connect, CD_TYPE type)
case CT_UNLINK: case CT_UNLINK:
if (m_linkState == DPLUS_LINKED) { if (m_linkState == DPLUS_LINKED) {
wxLogMessage(("D-Plus dongle link to %s has ended (unlinked)"), m_reflector.c_str()); CLog::logInfo(("D-Plus dongle link to %s has ended (unlinked)"), m_reflector.c_str());
m_stateChange = true; m_stateChange = true;
m_handler->writeConnect(connect); m_handler->writeConnect(connect);
} }
@ -769,13 +769,13 @@ bool CDPlusHandler::clockInt(unsigned int ms)
if (!m_reflector.empty()) { if (!m_reflector.empty()) {
switch (m_linkState) { switch (m_linkState) {
case DPLUS_LINKING: case DPLUS_LINKING:
wxLogMessage(("D-Plus link to %s has failed to connect"), m_reflector.c_str()); CLog::logInfo(("D-Plus link to %s has failed to connect"), m_reflector.c_str());
break; break;
case DPLUS_LINKED: case DPLUS_LINKED:
wxLogMessage(("D-Plus link to %s has failed (poll inactivity)"), m_reflector.c_str()); CLog::logInfo(("D-Plus link to %s has failed (poll inactivity)"), m_reflector.c_str());
break; break;
case DPLUS_UNLINKING: case DPLUS_UNLINKING:
wxLogMessage(("D-Plus link to %s has failed to disconnect cleanly"), m_reflector.c_str()); CLog::logInfo(("D-Plus link to %s has failed to disconnect cleanly"), m_reflector.c_str());
break; break;
default: default:
break; break;

@ -22,6 +22,7 @@
#include "DPlusProtocolHandlerPool.h" #include "DPlusProtocolHandlerPool.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
CDPlusProtocolHandlerPool::CDPlusProtocolHandlerPool(const unsigned int port, const std::string &addr) : CDPlusProtocolHandlerPool::CDPlusProtocolHandlerPool(const unsigned int port, const std::string &addr) :
m_basePort(port), m_basePort(port),
@ -29,7 +30,7 @@ m_address(addr)
{ {
assert(port > 0U); assert(port > 0U);
m_index = m_pool.end(); m_index = m_pool.end();
printf("DExtra UDP port base = %u\n", port); CLog::logInfo("DExtra UDP port base = %u\n", port);
} }
CDPlusProtocolHandlerPool::~CDPlusProtocolHandlerPool() CDPlusProtocolHandlerPool::~CDPlusProtocolHandlerPool()
@ -60,14 +61,14 @@ CDPlusProtocolHandler* CDPlusProtocolHandlerPool::getHandler(unsigned int port)
if (proto) { if (proto) {
if (proto->open()) { if (proto->open()) {
m_pool[port] = proto; m_pool[port] = proto;
printf("New CDPlusProtocolHandler now on UDP port %u.\n", port); CLog::logInfo("New CDPlusProtocolHandler now on UDP port %u.\n", port);
} else { } else {
delete proto; delete proto;
proto = NULL; proto = NULL;
printf("ERROR: Can't open new DPlus UDP port %u!\n", port); CLog::logInfo("ERROR: Can't open new DPlus UDP port %u!\n", port);
} }
} else } else
printf("ERROR: Can't allocate new CDPlusProtocolHandler at port %u\n", port); CLog::logInfo("ERROR: Can't allocate new CDPlusProtocolHandler at port %u\n", port);
return proto; return proto;
} }
@ -78,13 +79,13 @@ void CDPlusProtocolHandlerPool::release(CDPlusProtocolHandler *handler)
if (it->second == handler) { if (it->second == handler) {
it->second->close(); it->second->close();
delete it->second; delete it->second;
printf("Releasing CDPlusProtocolHandler on port %u.\n", it->first); CLog::logInfo("Releasing CDPlusProtocolHandler on port %u.\n", it->first);
m_pool.erase(it); m_pool.erase(it);
return; return;
} }
} }
// we should never get here! // we should never get here!
printf("ERROR: could not find CDPlusProtocolHander (port=%u) to release!\n", handler->getPort()); CLog::logInfo("ERROR: could not find CDPlusProtocolHander (port=%u) to release!\n", handler->getPort());
} }
DPLUS_TYPE CDPlusProtocolHandlerPool::read() DPLUS_TYPE CDPlusProtocolHandlerPool::read()

@ -31,6 +31,7 @@
#include "IRCDDBMultiClient.h" #include "IRCDDBMultiClient.h"
#include "IRCDDBClient.h" #include "IRCDDBClient.h"
#include "Utils.h" #include "Utils.h"
#include "Version.h"
#include "GitVersion.h" #include "GitVersion.h"
#include "RepeaterProtocolHandlerFactory.h" #include "RepeaterProtocolHandlerFactory.h"
#include "Log.h" #include "Log.h"
@ -54,7 +55,7 @@ int main(int argc, char *argv[])
std::string cfgFile(argv[1]); std::string cfgFile(argv[1]);
CDStarGatewayApp gateway(cfgFile); CDStarGatewayApp gateway(cfgFile);
if (!gateway.init()) { if (!gateway.init()) {
return 1; return 1;
} }
@ -81,7 +82,7 @@ void CDStarGatewayApp::run()
{ {
m_thread->Run(); m_thread->Run();
m_thread->Wait(); m_thread->Wait();
printf("exiting\n"); CLog::logInfo("exiting\n");
} }
bool CDStarGatewayApp::createThread() bool CDStarGatewayApp::createThread()
@ -92,12 +93,13 @@ bool CDStarGatewayApp::createThread()
CDStarGatewayConfig config(m_configFile); CDStarGatewayConfig config(m_configFile);
if(!config.load()) { if(!config.load()) {
wxLogError("FATAL: Invalid configuration"); CLog::logError("FATAL: Invalid configuration");
return false; return false;
} }
Tpaths paths; Tpaths paths;
config.getPaths(paths); config.getPaths(paths);
CLog::initialize(paths.logDir + "dstargateway.log", LS_INFO, true);
m_thread = new CDStarGatewayThread(paths.logDir, paths.dataDir, ""); m_thread = new CDStarGatewayThread(paths.logDir, paths.dataDir, "");
// Setup the gateway // Setup the gateway
@ -126,8 +128,7 @@ bool CDStarGatewayApp::createThread()
for(unsigned int i=0; i < config.getIrcDDBCount(); i++) { for(unsigned int i=0; i < config.getIrcDDBCount(); i++) {
TircDDB ircDDBConfig; TircDDB ircDDBConfig;
config.getIrcDDB(i, ircDDBConfig); config.getIrcDDB(i, ircDDBConfig);
std::cout << "ircDDB " << i + 1 << " set to " << ircDDBConfig.hostname << " username set to " << ircDDBConfig.username << " QuadNet " << ircDDBConfig.isQuadNet << std::endl; CLog::logInfo("ircDDB Network %d set to %s user: %s, Quadnet %d", i + 1,ircDDBConfig.hostname.c_str(), ircDDBConfig.username.c_str(), ircDDBConfig.isQuadNet);
CIRCDDB * ircDDB = new CIRCDDBClient(ircDDBConfig.hostname, 9007U, ircDDBConfig.username, ircDDBConfig.password, std::string("DStarGateway") + std::string("-") + VERSION, gatewayConfig.address, ircDDBConfig.isQuadNet); CIRCDDB * ircDDB = new CIRCDDBClient(ircDDBConfig.hostname, 9007U, ircDDBConfig.username, ircDDBConfig.password, std::string("DStarGateway") + std::string("-") + VERSION, gatewayConfig.address, ircDDBConfig.isQuadNet);
clients.push_back(ircDDB); clients.push_back(ircDDB);
} }
@ -135,7 +136,7 @@ bool CDStarGatewayApp::createThread()
CIRCDDBMultiClient* multiClient = new CIRCDDBMultiClient(clients); CIRCDDBMultiClient* multiClient = new CIRCDDBMultiClient(clients);
bool res = multiClient->open(); bool res = multiClient->open();
if (!res) { if (!res) {
wxLogMessage("Cannot initialise the ircDDB protocol handler\n"); CLog::logInfo("Cannot initialise the ircDDB protocol handler\n");
return false; return false;
} }
@ -143,7 +144,7 @@ bool CDStarGatewayApp::createThread()
// Setup the repeaters // Setup the repeaters
if(config.getRepeaterCount() == 0U) { if(config.getRepeaterCount() == 0U) {
wxLogMessage("No repeater configured\n"); CLog::logInfo("No repeater configured\n");
return false; return false;
} }
CRepeaterHandlerFactory repeaterProtocolFactory; CRepeaterHandlerFactory repeaterProtocolFactory;
@ -189,7 +190,7 @@ bool CDStarGatewayApp::createThread()
// repeater.resize(7, ' '); // repeater.resize(7, ' ');
// repeater.push_back(band[0]); // repeater.push_back(band[0]);
// m_thread->addGroup(callsign, logoff, repeater, info, permanent, usertimeout, callsignswitch, txmsgswitch, reflector); // m_thread->addGroup(callsign, logoff, repeater, info, permanent, usertimeout, callsignswitch, txmsgswitch, reflector);
// printf("Group %d: %s/%s using %s, \"%s\", perm: %s, timeout: %u mins, c/s switch: %s, msg switch: %s, Linked: %s\n", // CLog::logInfo("Group %d: %s/%s using %s, \"%s\", perm: %s, timeout: %u mins, c/s switch: %s, msg switch: %s, Linked: %s\n",
// i, callsign.c_str(), logoff.c_str(), repeater.c_str(), info.c_str(), permanent.c_str(), usertimeout, // i, callsign.c_str(), logoff.c_str(), repeater.c_str(), info.c_str(), permanent.c_str(), usertimeout,
// SCS_GROUP_CALLSIGN==callsignswitch ? "Group" : "User", txmsgswitch ? "true" : "false", reflector.c_str()); // SCS_GROUP_CALLSIGN==callsignswitch ? "Group" : "User", txmsgswitch ? "true" : "false", reflector.c_str());
// } // }
@ -199,7 +200,7 @@ bool CDStarGatewayApp::createThread()
// std::string remotePassword; // std::string remotePassword;
// unsigned int remotePort; // unsigned int remotePort;
// config.getRemote(remoteEnabled, remotePassword, remotePort); // config.getRemote(remoteEnabled, remotePassword, remotePort);
// printf("Remote enabled set to %d, port set to %u\n", int(remoteEnabled), remotePort); // CLog::logInfo("Remote enabled set to %d, port set to %u\n", int(remoteEnabled), remotePort);
// m_thread->setRemote(remoteEnabled, remotePassword, remotePort); // m_thread->setRemote(remoteEnabled, remotePassword, remotePort);
// m_thread->setAddress(address); // m_thread->setAddress(address);

@ -25,6 +25,7 @@
#include "Utils.h" #include "Utils.h"
#include "DStarGatewayConfig.h" #include "DStarGatewayConfig.h"
#include "DStarDefines.h" #include "DStarDefines.h"
#include "Log.h"
CDStarGatewayConfig::CDStarGatewayConfig(const std::string &pathname) CDStarGatewayConfig::CDStarGatewayConfig(const std::string &pathname)
: m_fileName(pathname) : m_fileName(pathname)
@ -34,6 +35,7 @@ CDStarGatewayConfig::CDStarGatewayConfig(const std::string &pathname)
bool CDStarGatewayConfig::load() bool CDStarGatewayConfig::load()
{ {
CLog::logInfo("Loading configuration from %s", m_fileName.c_str());
Config cfg; Config cfg;
if(open(cfg) if(open(cfg)
&& loadGateway(cfg) && loadGateway(cfg)
@ -49,6 +51,8 @@ bool CDStarGatewayConfig::load()
return true; return true;
} }
CLog::logError("Loading configuration from %s failed", m_fileName.c_str());
return false; return false;
} }
@ -189,12 +193,12 @@ bool CDStarGatewayConfig::loadRepeaters(const Config & cfg)
isOk = true; isOk = true;
} }
else { else {
std::cout << "Repeater " << i << " has an empty callsign" << std::endl ; CLog::logError("Repeater %d has an empty callsign", i);
} }
if (isOk && !isalpha(repeater->band[0])) { if (isOk && !isalpha(repeater->band[0])) {
isOk = false; isOk = false;
std::cout << "Repeater " << i << " band is not a letter" << std::endl; CLog::logError("Repeater %s band is not a letter", i);
} }
if (isOk && repeater->address.length() == 0) { if (isOk && repeater->address.length() == 0) {
@ -204,7 +208,6 @@ bool CDStarGatewayConfig::loadRepeaters(const Config & cfg)
if(!isOk) { if(!isOk) {
delete repeater; delete repeater;
} else { } else {
std::cout << "REPEATER: " << repeater->callsign << "-" << repeater->band << " " << repeater->address << ":" << repeater->port << std::endl;
m_repeaters.push_back(repeater); m_repeaters.push_back(repeater);
} }
} }
@ -241,7 +244,6 @@ bool CDStarGatewayConfig::loadIrcDDB(const Config & cfg)
ircddb->isQuadNet = ircddb->hostname.find("openquad.net") != std::string::npos; ircddb->isQuadNet = ircddb->hostname.find("openquad.net") != std::string::npos;
this->m_ircDDB.push_back(ircddb); this->m_ircDDB.push_back(ircddb);
std::cout << "IRCDDB: host=" << ircddb->hostname << " user=" << ircddb->username << " password=" << ircddb->password << std::endl;
} }
if(this->m_ircDDB.size() == 0) {//no ircddb network specified? Default to openquad! if(this->m_ircDDB.size() == 0) {//no ircddb network specified? Default to openquad!
@ -251,7 +253,7 @@ bool CDStarGatewayConfig::loadIrcDDB(const Config & cfg)
ircddb->username = m_gateway.callsign; ircddb->username = m_gateway.callsign;
ircddb->isQuadNet = true; ircddb->isQuadNet = true;
this->m_ircDDB.push_back(ircddb); this->m_ircDDB.push_back(ircddb);
std::cout << "No ircDDB networks configured, defaulting to IRCDDB: host=" << ircddb->hostname << " user=" << ircddb->username << " password=" << ircddb->password << "\n"; CLog::logError("No ircDDB networks configured, defaulting to IRCDDB: host=%s user=%s", ircddb->hostname.c_str(), ircddb->username.c_str());
} }
return true; return true;
@ -292,8 +294,6 @@ bool CDStarGatewayConfig::loadGateway(const Config & cfg)
else if(lang == "norsk") m_gateway.language = TL_NORSK; else if(lang == "norsk") m_gateway.language = TL_NORSK;
else if(lang == "portugues") m_gateway.language = TL_PORTUGUES; else if(lang == "portugues") m_gateway.language = TL_PORTUGUES;
std::cout << "GATEWAY: callsign='" << m_gateway.callsign << "' listen address='" << m_gateway.address << std::endl;
CUtils::ToUpper(m_gateway.callsign); CUtils::ToUpper(m_gateway.callsign);
CUtils::clean(m_gateway.description1, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,&*()-+=@/?:;"); CUtils::clean(m_gateway.description1, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,&*()-+=@/?:;");
CUtils::clean(m_gateway.description2, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,&*()-+=@/?:;"); CUtils::clean(m_gateway.description2, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,&*()-+=@/?:;");
@ -305,7 +305,7 @@ bool CDStarGatewayConfig::loadGateway(const Config & cfg)
bool CDStarGatewayConfig::open(Config & cfg) bool CDStarGatewayConfig::open(Config & cfg)
{ {
if (m_fileName.size() < 1) { if (m_fileName.size() < 1) {
printf("Configuration filename too short!\n"); CLog::logError("Configuration filename too short!\n");
return false; return false;
} }
@ -313,11 +313,11 @@ bool CDStarGatewayConfig::open(Config & cfg)
cfg.readFile(m_fileName.c_str()); cfg.readFile(m_fileName.c_str());
} }
catch(const FileIOException &fioex) { catch(const FileIOException &fioex) {
printf("Can't read %s\n", m_fileName.c_str()); CLog::logError("Can't read %s\n", m_fileName.c_str());
return false; return false;
} }
catch(const ParseException &pex) { catch(const ParseException &pex) {
printf("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError()); CLog::logError("Parse error at %s:%d - %s\n", pex.getFile(), pex.getLine(), pex.getError());
return false; return false;
} }
@ -386,7 +386,7 @@ bool CDStarGatewayConfig::get_value(const Config &cfg, const std::string &path,
if (cfg.lookupValue(path, value)) { if (cfg.lookupValue(path, value)) {
int l = value.length(); int l = value.length();
if (l<min || l>max) { if (l<min || l>max) {
std::cout << path << "=" << value << " has an inalid length, must be between " << min << " and " << max << " actual " << l << "\n"; CLog::logWarning("%s has an invalid length, must be between %d and %d, actual %d", path.c_str(), min, max, l);
return false; return false;
} }
} else } else
@ -418,8 +418,7 @@ bool CDStarGatewayConfig::get_value(const Config &cfg, const std::string &path,
for(std::string s : allowedValues) { for(std::string s : allowedValues) {
message << s << ", "; message << s << ", ";
} }
message << std::endl; CLog::logWarning(message.str());
std::cout << message.str();
} }
return ret; return ret;

@ -157,7 +157,7 @@ void* CDStarGatewayThread::Entry()
fullName += fullName + m_name; fullName += fullName + m_name;
} }
CUtils::truncateFile(fullName); CUtils::truncateFile(fullName);
wxLogMessage("Truncating %s", fullName.c_str()); CLog::logInfo("Truncating %s", fullName.c_str());
#ifdef USE_STARNET #ifdef USE_STARNET
// Truncate the old StarNet.log file // Truncate the old StarNet.log file
@ -166,7 +166,7 @@ void* CDStarGatewayThread::Entry()
fullName += fullName + m_name; fullName += fullName + m_name;
} }
CUtils::truncateFile(fullName); CUtils::truncateFile(fullName);
wxLogMessage("Truncating %s", fullName.c_str()); CLog::logInfo("Truncating %s", fullName.c_str());
#endif #endif
std::string dextraAddress = m_dextraEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS; std::string dextraAddress = m_dextraEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS;
@ -178,7 +178,7 @@ void* CDStarGatewayThread::Entry()
CDExtraHandler::setDExtraProtocolHandlerPool(m_dextraPool); CDExtraHandler::setDExtraProtocolHandlerPool(m_dextraPool);
} }
else { else {
wxLogError("Failed to allocate incoming DExtra handler\n"); CLog::logError("Failed to allocate incoming DExtra handler\n");
} }
@ -189,7 +189,7 @@ void* CDStarGatewayThread::Entry()
CDPlusHandler::setDPlusProtocolIncoming(dplusHandler); CDPlusHandler::setDPlusProtocolIncoming(dplusHandler);
CDPlusHandler::setDPlusProtocolHandlerPool(m_dplusPool); CDPlusHandler::setDPlusProtocolHandlerPool(m_dplusPool);
} else { } else {
wxLogError("Failed to allocate incoming DPlus handler\n"); CLog::logError("Failed to allocate incoming DPlus handler\n");
} }
std::string dcsAddress = m_dcsEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS; std::string dcsAddress = m_dcsEnabled ? m_gatewayAddress : LOOPBACK_ADDRESS;
@ -199,13 +199,13 @@ void* CDStarGatewayThread::Entry()
CDCSHandler::setDCSProtocolIncoming(dcsHandler); CDCSHandler::setDCSProtocolIncoming(dcsHandler);
CDCSHandler::setDCSProtocolHandlerPool(m_dcsPool); CDCSHandler::setDCSProtocolHandlerPool(m_dcsPool);
} else { } else {
wxLogError("Failed to allocate incoming DCS handler\n"); CLog::logError("Failed to allocate incoming DCS handler\n");
} }
m_g2Handler = new CG2ProtocolHandler(G2_DV_PORT, m_gatewayAddress); m_g2Handler = new CG2ProtocolHandler(G2_DV_PORT, m_gatewayAddress);
bool ret = m_g2Handler->open(); bool ret = m_g2Handler->open();
if (!ret) { if (!ret) {
wxLogError("Could not open the G2 protocol handler"); CLog::logError("Could not open the G2 protocol handler");
delete m_g2Handler; delete m_g2Handler;
m_g2Handler = NULL; m_g2Handler = NULL;
} }
@ -226,7 +226,7 @@ void* CDStarGatewayThread::Entry()
m_stopped = false; m_stopped = false;
wxLogMessage("Starting the ircDDB Gateway thread"); CLog::logInfo("Starting the ircDDB Gateway thread");
CHeaderLogger* headerLogger = NULL; CHeaderLogger* headerLogger = NULL;
if (m_logEnabled) { if (m_logEnabled) {
@ -427,13 +427,13 @@ void* CDStarGatewayThread::Entry()
} }
catch (std::exception& e) { catch (std::exception& e) {
std::string message(e.what()); std::string message(e.what());
wxLogError("Exception raised in the main thread - \"%s\"", message.c_str()); CLog::logError("Exception raised in the main thread - \"%s\"", message.c_str());
} }
catch (...) { catch (...) {
wxLogError("Unknown exception raised in the main thread"); CLog::logError("Unknown exception raised in the main thread");
} }
wxLogMessage("Stopping the ircDDB Gateway thread"); CLog::logInfo("Stopping the ircDDB Gateway thread");
// Unlink from all reflectors // Unlink from all reflectors
CDExtraHandler::unlink(); CDExtraHandler::unlink();
@ -526,7 +526,7 @@ void CDStarGatewayThread::addRepeater(const std::string& callsign, const std::st
// Add a fixed address and protocol for the local repeaters // Add a fixed address and protocol for the local repeaters
m_cache.updateRepeater(repeater, m_gatewayCallsign, "127.0.0.1", DP_LOOPBACK, true, true); m_cache.updateRepeater(repeater, m_gatewayCallsign, "127.0.0.1", DP_LOOPBACK, true, true);
wxLogMessage("Adding %s to the cache as a local repeater", repeater.c_str()); CLog::logInfo("Adding %s to the cache as a local repeater", repeater.c_str());
} }
#ifdef USE_STARNET #ifdef USE_STARNET
@ -615,14 +615,14 @@ void CDStarGatewayThread::setCCS(bool enabled, const std::string& host)
wxFileName fileName(wxFileName::GetHomeDir(), CCS_HOSTS_FILE_NAME); wxFileName fileName(wxFileName::GetHomeDir(), CCS_HOSTS_FILE_NAME);
if (!fileName.IsFileReadable()) { if (!fileName.IsFileReadable()) {
wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str()); CLog::logInfo(wxT("File %s not readable"), fileName.GetFullPath().c_str());
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
fileName.Assign(::wxGetCwd(), CCS_HOSTS_FILE_NAME); fileName.Assign(::wxGetCwd(), CCS_HOSTS_FILE_NAME);
#else #else
fileName.Assign(wxT(m_dataDir), CCS_HOSTS_FILE_NAME); fileName.Assign(wxT(m_dataDir), CCS_HOSTS_FILE_NAME);
#endif #endif
if (!fileName.IsFileReadable()) { if (!fileName.IsFileReadable()) {
wxLogMessage(wxT("File %s not readable"), fileName.GetFullPath().c_str()); CLog::logInfo(wxT("File %s not readable"), fileName.GetFullPath().c_str());
m_ccsEnabled = false; m_ccsEnabled = false;
return; return;
} }
@ -713,19 +713,19 @@ void CDStarGatewayThread::processIrcDDB()
case 0: case 0:
case 10: case 10:
if (m_lastStatus != IS_DISCONNECTED) { if (m_lastStatus != IS_DISCONNECTED) {
wxLogInfo("Disconnected from ircDDB"); CLog::logInfo("Disconnected from ircDDB");
m_lastStatus = IS_DISCONNECTED; m_lastStatus = IS_DISCONNECTED;
} }
break; break;
case 7: case 7:
if (m_lastStatus != IS_CONNECTED) { if (m_lastStatus != IS_CONNECTED) {
wxLogInfo("Connected to ircDDB"); CLog::logInfo("Connected to ircDDB");
m_lastStatus = IS_CONNECTED; m_lastStatus = IS_CONNECTED;
} }
break; break;
default: default:
if (m_lastStatus != IS_CONNECTING) { if (m_lastStatus != IS_CONNECTING) {
wxLogInfo("Connecting to ircDDB"); CLog::logInfo("Connecting to ircDDB");
m_lastStatus = IS_CONNECTING; m_lastStatus = IS_CONNECTING;
} }
break; break;
@ -746,13 +746,13 @@ void CDStarGatewayThread::processIrcDDB()
break; break;
if (!address.empty()) { if (!address.empty()) {
wxLogMessage("USER: %s %s %s %s", user.c_str(), repeater.c_str(), gateway.c_str(), address.c_str()); CLog::logInfo("USER: %s %s %s %s", user.c_str(), repeater.c_str(), gateway.c_str(), address.c_str());
m_cache.updateUser(user, repeater, gateway, address, timestamp, DP_DEXTRA, false, false); m_cache.updateUser(user, repeater, gateway, address, timestamp, DP_DEXTRA, false, false);
#if defined(ENABLE_NAT_TRAVERSAL) #if defined(ENABLE_NAT_TRAVERSAL)
m_natTraversal->traverseNatG2(address); m_natTraversal->traverseNatG2(address);
#endif #endif
} else { } else {
wxLogMessage("USER: %s NOT FOUND", user.c_str()); CLog::logInfo("USER: %s NOT FOUND", user.c_str());
} }
} }
break; break;
@ -765,13 +765,13 @@ void CDStarGatewayThread::processIrcDDB()
CRepeaterHandler::resolveRepeater(repeater, gateway, address, DP_DEXTRA); CRepeaterHandler::resolveRepeater(repeater, gateway, address, DP_DEXTRA);
if (!address.empty()) { if (!address.empty()) {
wxLogMessage("REPEATER: %s %s %s", repeater.c_str(), gateway.c_str(), address.c_str()); CLog::logInfo("REPEATER: %s %s %s", repeater.c_str(), gateway.c_str(), address.c_str());
m_cache.updateRepeater(repeater, gateway, address, DP_DEXTRA, false, false); m_cache.updateRepeater(repeater, gateway, address, DP_DEXTRA, false, false);
#if defined(ENABLE_NAT_TRAVERSAL) #if defined(ENABLE_NAT_TRAVERSAL)
m_natTraversal->traverseNatG2(address); m_natTraversal->traverseNatG2(address);
#endif #endif
} else { } else {
wxLogMessage("REPEATER: %s NOT FOUND", repeater.c_str()); CLog::logInfo("REPEATER: %s NOT FOUND", repeater.c_str());
} }
} }
break; break;
@ -785,13 +785,13 @@ void CDStarGatewayThread::processIrcDDB()
CDExtraHandler::gatewayUpdate(gateway, address); CDExtraHandler::gatewayUpdate(gateway, address);
CDPlusHandler::gatewayUpdate(gateway, address); CDPlusHandler::gatewayUpdate(gateway, address);
if (!address.empty()) { if (!address.empty()) {
wxLogMessage("GATEWAY: %s %s", gateway.c_str(), address.c_str()); CLog::logInfo("GATEWAY: %s %s", gateway.c_str(), address.c_str());
m_cache.updateGateway(gateway, address, DP_DEXTRA, false, false); m_cache.updateGateway(gateway, address, DP_DEXTRA, false, false);
#if defined(ENABLE_NAT_TRAVERSAL) #if defined(ENABLE_NAT_TRAVERSAL)
m_natTraversal->traverseNatG2(address); m_natTraversal->traverseNatG2(address);
#endif #endif
} else { } else {
wxLogMessage("GATEWAY: %s NOT FOUND", gateway.c_str()); CLog::logInfo("GATEWAY: %s NOT FOUND", gateway.c_str());
} }
} }
break; break;
@ -832,7 +832,7 @@ void CDStarGatewayThread::processRepeater(IRepeaterProtocolHandler* handler)
if (repeater != user) { if (repeater != user) {
CRepeaterHandler* handler = CRepeaterHandler::findDVRepeater(repeater); CRepeaterHandler* handler = CRepeaterHandler::findDVRepeater(repeater);
if (handler == NULL) if (handler == NULL)
wxLogMessage("Heard received from unknown repeater, %s", repeater.c_str()); CLog::logInfo("Heard received from unknown repeater, %s", repeater.c_str());
else else
handler->processRepeater(*heard); handler->processRepeater(*heard);
@ -845,11 +845,11 @@ void CDStarGatewayThread::processRepeater(IRepeaterProtocolHandler* handler)
case RT_HEADER: { case RT_HEADER: {
CHeaderData* header = handler->readHeader(); CHeaderData* header = handler->readHeader();
if (header != NULL) { if (header != NULL) {
// wxLogMessage(wxT("Repeater header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str(), header->getFlag1(), header->getFlag2(), header->getFlag3()); // CLog::logInfo(wxT("Repeater header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str(), header->getFlag1(), header->getFlag2(), header->getFlag3());
CRepeaterHandler* repeater = CRepeaterHandler::findDVRepeater(*header); CRepeaterHandler* repeater = CRepeaterHandler::findDVRepeater(*header);
if (repeater == NULL) if (repeater == NULL)
wxLogMessage("Header received from unknown repeater, %s", header->getRptCall1().c_str()); CLog::logInfo("Header received from unknown repeater, %s", header->getRptCall1().c_str());
else else
repeater->processRepeater(*header); repeater->processRepeater(*header);
@ -873,11 +873,11 @@ void CDStarGatewayThread::processRepeater(IRepeaterProtocolHandler* handler)
case RT_BUSY_HEADER: { case RT_BUSY_HEADER: {
CHeaderData* header = handler->readBusyHeader(); CHeaderData* header = handler->readBusyHeader();
if (header != NULL) { if (header != NULL) {
// wxLogMessage(wxT("Repeater busy header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str(), header->getFlag1(), header->getFlag2(), header->getFlag3()); // CLog::logInfo(wxT("Repeater busy header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str(), header->getFlag1(), header->getFlag2(), header->getFlag3());
CRepeaterHandler* repeater = CRepeaterHandler::findDVRepeater(*header); CRepeaterHandler* repeater = CRepeaterHandler::findDVRepeater(*header);
if (repeater == NULL) if (repeater == NULL)
wxLogMessage("Busy header received from unknown repeater, %s", header->getRptCall1().c_str()); CLog::logInfo("Busy header received from unknown repeater, %s", header->getRptCall1().c_str());
else else
repeater->processBusy(*header); repeater->processBusy(*header);
@ -901,11 +901,11 @@ void CDStarGatewayThread::processRepeater(IRepeaterProtocolHandler* handler)
case RT_DD: { case RT_DD: {
CDDData* data = handler->readDD(); CDDData* data = handler->readDD();
if (data != NULL) { if (data != NULL) {
// wxLogMessage(wxT("DD header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), data->getMyCall1().c_str(), data->getMyCall2().c_str(), data->getYourCall().c_str(), data->getRptCall1().c_str(), data->getRptCall2().c_str(), data->getFlag1(), data->getFlag2(), data->getFlag3()); // CLog::logInfo(wxT("DD header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), data->getMyCall1().c_str(), data->getMyCall2().c_str(), data->getYourCall().c_str(), data->getRptCall1().c_str(), data->getRptCall2().c_str(), data->getFlag1(), data->getFlag2(), data->getFlag3());
CRepeaterHandler* repeater = CRepeaterHandler::findDDRepeater(); CRepeaterHandler* repeater = CRepeaterHandler::findDDRepeater();
if (repeater == NULL) if (repeater == NULL)
wxLogMessage("DD data received from unknown DD repeater, %s", data->getRptCall1().c_str()); CLog::logInfo("DD data received from unknown DD repeater, %s", data->getRptCall1().c_str());
else else
repeater->processRepeater(*data); repeater->processRepeater(*data);
@ -947,7 +947,7 @@ void CDStarGatewayThread::processDExtra()
case DE_HEADER: { case DE_HEADER: {
CHeaderData* header = m_dextraPool->readHeader(); CHeaderData* header = m_dextraPool->readHeader();
if (header != NULL) { if (header != NULL) {
// wxLogMessage(wxT("DExtra header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str()); // CLog::logInfo(wxT("DExtra header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str());
CDExtraHandler::process(*header); CDExtraHandler::process(*header);
delete header; delete header;
} }
@ -996,7 +996,7 @@ void CDStarGatewayThread::processDPlus()
case DP_HEADER: { case DP_HEADER: {
CHeaderData* header = m_dplusPool->readHeader(); CHeaderData* header = m_dplusPool->readHeader();
if (header != NULL) { if (header != NULL) {
// wxLogMessage(wxT("D-Plus header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str()); // CLog::logInfo(wxT("D-Plus header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str());
CDPlusHandler::process(*header); CDPlusHandler::process(*header);
delete header; delete header;
} }
@ -1045,7 +1045,7 @@ void CDStarGatewayThread::processDCS()
case DC_DATA: { case DC_DATA: {
CAMBEData* data = m_dcsPool->readData(); CAMBEData* data = m_dcsPool->readData();
if (data != NULL) { if (data != NULL) {
// wxLogMessage(wxT("DCS header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str()); // CLog::logInfo(wxT("DCS header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str());
CDCSHandler::process(*data); CDCSHandler::process(*data);
delete data; delete data;
} }
@ -1067,7 +1067,7 @@ void CDStarGatewayThread::processG2()
case GT_HEADER: { case GT_HEADER: {
CHeaderData* header = m_g2Handler->readHeader(); CHeaderData* header = m_g2Handler->readHeader();
if (header != NULL) { if (header != NULL) {
// wxLogMessage(wxT("G2 header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str(), header->getFlag1(), header->getFlag2(), header->getFlag3()); // CLog::logInfo(wxT("G2 header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), header->getMyCall1().c_str(), header->getMyCall2().c_str(), header->getYourCall().c_str(), header->getRptCall1().c_str(), header->getRptCall2().c_str(), header->getFlag1(), header->getFlag2(), header->getFlag3());
CG2Handler::process(*header); CG2Handler::process(*header);
delete header; delete header;
} }
@ -1096,7 +1096,7 @@ void CDStarGatewayThread::processDD()
if (data == NULL) if (data == NULL)
return; return;
// wxLogMessage(wxT("DD header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), data->getMyCall1().c_str(), data->getMyCall2().c_str(), data->getYourCall().c_str(), data->getRptCall1().c_str(), data->getRptCall2().c_str(), data->getFlag1(), data->getFlag2(), data->getFlag3()); // CLog::logInfo(wxT("DD header - My: %s/%s Your: %s Rpt1: %s Rpt2: %s Flags: %02X %02X %02X"), data->getMyCall1().c_str(), data->getMyCall2().c_str(), data->getYourCall().c_str(), data->getRptCall1().c_str(), data->getRptCall2().c_str(), data->getFlag1(), data->getFlag2(), data->getFlag3());
delete data; delete data;
} }
@ -1147,7 +1147,7 @@ void CDStarGatewayThread::loadReflectors(std::string hostFileName, DSTAR_PROTOCO
addrText = CStringUtils::string_format("%u.%u.%u.%u", ucp[0U] & 0xFFU, ucp[1U] & 0xFFU, ucp[2U] & 0xFFU, ucp[3U] & 0xFFU); addrText = CStringUtils::string_format("%u.%u.%u.%u", ucp[0U] & 0xFFU, ucp[1U] & 0xFFU, ucp[2U] & 0xFFU, ucp[3U] & 0xFFU);
if (lock) if (lock)
wxLogMessage("Locking %s to %s", reflector.c_str(), addrText.c_str()); CLog::logInfo("Locking %s to %s", reflector.c_str(), addrText.c_str());
reflector.resize(LONG_CALLSIGN_LENGTH - 1U, ' '); reflector.resize(LONG_CALLSIGN_LENGTH - 1U, ' ');
reflector += "G"; reflector += "G";
@ -1174,7 +1174,7 @@ void CDStarGatewayThread::loadReflectors(std::string hostFileName, DSTAR_PROTOCO
break; break;
} }
wxLogMessage("Loaded %u of %u %s hosts from %s", count, hostFile.getCount(), protoString.c_str() , hostFileName.c_str()); CLog::logInfo("Loaded %u of %u %s hosts from %s", count, hostFile.getCount(), protoString.c_str() , hostFileName.c_str());
} }
void CDStarGatewayThread::writeStatus() void CDStarGatewayThread::writeStatus()
@ -1190,7 +1190,7 @@ void CDStarGatewayThread::writeStatus()
std::ofstream file; std::ofstream file;
file.open(fullName, std::fstream::trunc); file.open(fullName, std::fstream::trunc);
if (!file.is_open()) { if (!file.is_open()) {
wxLogError("Unable to open %s for writing", fullName.c_str()); CLog::logError("Unable to open %s for writing", fullName.c_str());
return; return;
} }
@ -1270,7 +1270,7 @@ void CDStarGatewayThread::readStatusFile(const std::string& filename, unsigned i
} }
if(var != text) { if(var != text) {
wxLogMessage("Status %u message set to \"%s\"", n + 1U, text.c_str()); CLog::logInfo("Status %u message set to \"%s\"", n + 1U, text.c_str());
CStatusData statusData(text, n); CStatusData statusData(text, n);
CRepeaterHandler::writeStatus(statusData); CRepeaterHandler::writeStatus(statusData);
var = text; var = text;

@ -41,7 +41,7 @@ bool CDummyRepeaterProtocolHandler::writeHeader(CHeaderData& header)
unsigned char buffer[50U]; unsigned char buffer[50U];
unsigned int length = header.getHBRepeaterData(buffer, 50U, true); unsigned int length = header.getHBRepeaterData(buffer, 50U, true);
wxLogMessage("Sending Header to port: %u, id: %04X", header.getYourPort(), header.getId()); CLog::logInfo("Sending Header to port: %u, id: %04X", header.getYourPort(), header.getId());
CUtils::dump("Data", buffer + 8U, length - 8U); CUtils::dump("Data", buffer + 8U, length - 8U);
@ -53,7 +53,7 @@ bool CDummyRepeaterProtocolHandler::writeAMBE(CAMBEData& data)
unsigned char buffer[30U]; unsigned char buffer[30U];
unsigned int length = data.getHBRepeaterData(buffer, 30U); unsigned int length = data.getHBRepeaterData(buffer, 30U);
wxLogMessage("Sending AMBE to port: %u, seq: %02X, id: %04X", data.getYourPort(), data.getSeq(), data.getId()); CLog::logInfo("Sending AMBE to port: %u, seq: %02X, id: %04X", data.getYourPort(), data.getSeq(), data.getId());
CUtils::dump("Data", buffer + 9U, length - 9U); CUtils::dump("Data", buffer + 9U, length - 9U);

@ -24,6 +24,7 @@
#include "EchoUnit.h" #include "EchoUnit.h"
#include "Defs.h" #include "Defs.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
const unsigned int MAX_FRAMES = 60U * DSTAR_FRAMES_PER_SEC; const unsigned int MAX_FRAMES = 60U * DSTAR_FRAMES_PER_SEC;
@ -73,7 +74,7 @@ void CEchoUnit::writeData(const CAMBEData& data)
} }
if (data.isEnd()) { if (data.isEnd()) {
printf("Received %.1f secs of audio from %s for echoing\n", float(m_in) / float(DSTAR_FRAMES_PER_SEC), m_header->getMyCall1().c_str()); CLog::logInfo("Received %.1f secs of audio from %s for echoing\n", float(m_in) / float(DSTAR_FRAMES_PER_SEC), m_header->getMyCall1().c_str());
m_timer.start(); m_timer.start();
m_status = ES_WAIT; m_status = ES_WAIT;
@ -85,7 +86,7 @@ void CEchoUnit::end()
if (m_status != ES_RECEIVE) if (m_status != ES_RECEIVE)
return; return;
printf("Received %.1f secs of audio from %s for echoing\n", float(m_in) / float(DSTAR_FRAMES_PER_SEC), m_header->getMyCall1().c_str()); CLog::logInfo("Received %.1f secs of audio from %s for echoing\n", float(m_in) / float(DSTAR_FRAMES_PER_SEC), m_header->getMyCall1().c_str());
m_timer.start(); m_timer.start();
m_status = ES_WAIT; m_status = ES_WAIT;

@ -78,7 +78,7 @@ void CG2Handler::process(CHeaderData& header)
unsigned char flag1 = header.getFlag1(); unsigned char flag1 = header.getFlag1();
if (flag1 == 0x01) { if (flag1 == 0x01) {
// Don't check the incoming stream // Don't check the incoming stream
// wxLogMessage(wxT("G2 busy message received")); // CLog::logInfo(wxT("G2 busy message received"));
return; return;
} }
@ -114,7 +114,7 @@ void CG2Handler::process(CHeaderData& header)
// Find the destination repeater // Find the destination repeater
CRepeaterHandler* repeater = CRepeaterHandler::findDVRepeater(header.getRptCall2()); CRepeaterHandler* repeater = CRepeaterHandler::findDVRepeater(header.getRptCall2());
if (repeater == NULL) { if (repeater == NULL) {
wxLogMessage("Incoming G2 header from %s to unknown repeater - %s", header.getMyCall1().c_str(), header.getRptCall2().c_str()); CLog::logInfo("Incoming G2 header from %s to unknown repeater - %s", header.getMyCall1().c_str(), header.getRptCall2().c_str());
return; // Not found, ignore return; // Not found, ignore
} }
@ -133,7 +133,7 @@ void CG2Handler::process(CHeaderData& header)
} }
} }
wxLogMessage("No space to add new G2 route, ignoring"); CLog::logInfo("No space to add new G2 route, ignoring");
delete route; delete route;
} }
@ -200,7 +200,7 @@ bool CG2Handler::clockInt(unsigned int ms)
m_inactivityTimer.clock(ms); m_inactivityTimer.clock(ms);
if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) { if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) {
wxLogMessage("Inactivity timeout for a G2 route has expired"); CLog::logInfo("Inactivity timeout for a G2 route has expired");
return true; return true;
} }

@ -18,8 +18,10 @@
*/ */
#include <string> #include <string>
#include "G2ProtocolHandler.h" #include "G2ProtocolHandler.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
// #define DUMP_TX // #define DUMP_TX
@ -109,11 +111,11 @@ bool CG2ProtocolHandler::readPackets()
// save the incoming port (this is to enable mobile hotspots) // save the incoming port (this is to enable mobile hotspots)
if (portmap.end() == portmap.find(m_address.s_addr)) { if (portmap.end() == portmap.find(m_address.s_addr)) {
printf("new address %s on port %u\n", inet_ntoa(m_address), m_port); CLog::logInfo("new address %s on port %u\n", inet_ntoa(m_address), m_port);
portmap[m_address.s_addr] = m_port; portmap[m_address.s_addr] = m_port;
} else { } else {
if (portmap[m_address.s_addr] != m_port) { if (portmap[m_address.s_addr] != m_port) {
printf("new port for %s is %u, was %u\n", inet_ntoa(m_address), m_port, portmap[m_address.s_addr]); CLog::logInfo("new port for %s is %u, was %u\n", inet_ntoa(m_address), m_port, portmap[m_address.s_addr]);
portmap[m_address.s_addr] = m_port; portmap[m_address.s_addr] = m_port;
} }
} }

@ -201,7 +201,7 @@ CHeaderData* CHBRepeaterProtocolHandler::readHeader()
bool res = header->setHBRepeaterData(m_buffer, m_length, true, m_address, m_port); bool res = header->setHBRepeaterData(m_buffer, m_length, true, m_address, m_port);
if (!res) { if (!res) {
wxLogError("Invalid checksum from the repeater"); CLog::logError("Invalid checksum from the repeater");
delete header; delete header;
return NULL; return NULL;
} }
@ -218,7 +218,7 @@ CAMBEData* CHBRepeaterProtocolHandler::readAMBE()
bool res = data->setHBRepeaterData(m_buffer, m_length, m_address, m_port); bool res = data->setHBRepeaterData(m_buffer, m_length, m_address, m_port);
if (!res) { if (!res) {
wxLogError("Invalid AMBE data from the repeater"); CLog::logError("Invalid AMBE data from the repeater");
delete data; delete data;
return NULL; return NULL;
} }
@ -235,7 +235,7 @@ CHeaderData* CHBRepeaterProtocolHandler::readBusyHeader()
bool res = header->setHBRepeaterData(m_buffer, m_length, true, m_address, m_port); bool res = header->setHBRepeaterData(m_buffer, m_length, true, m_address, m_port);
if (!res) { if (!res) {
wxLogError("Invalid checksum from the repeater"); CLog::logError("Invalid checksum from the repeater");
delete header; delete header;
return NULL; return NULL;
} }
@ -252,7 +252,7 @@ CAMBEData* CHBRepeaterProtocolHandler::readBusyAMBE()
bool res = data->setHBRepeaterData(m_buffer, m_length, m_address, m_port); bool res = data->setHBRepeaterData(m_buffer, m_length, m_address, m_port);
if (!res) { if (!res) {
wxLogError("Invalid AMBE data from the repeater"); CLog::logError("Invalid AMBE data from the repeater");
delete data; delete data;
return NULL; return NULL;
} }
@ -274,7 +274,7 @@ CDDData* CHBRepeaterProtocolHandler::readDD()
bool res = data->setHBRepeaterData(m_buffer, m_length, m_address, m_port); bool res = data->setHBRepeaterData(m_buffer, m_length, m_address, m_port);
if (!res) { if (!res) {
wxLogError("Invalid DD data from the repeater"); CLog::logError("Invalid DD data from the repeater");
delete data; delete data;
return NULL; return NULL;
} }

@ -52,7 +52,7 @@ bool CHeaderLogger::open()
m_file.open(fullName, std::ios::app); m_file.open(fullName, std::ios::app);
if (!m_file.is_open()) { if (!m_file.is_open()) {
wxLogError("Cannot open %s file for appending", fullName.c_str()); CLog::logError("Cannot open %s file for appending", fullName.c_str());
return false; return false;
} }

@ -39,7 +39,7 @@ m_locks()
return; return;
if (logging) if (logging)
wxLogMessage("Reading %s", fileName.c_str()); CLog::logInfo("Reading %s", fileName.c_str());
while(!file.eof()) { while(!file.eof()) {
std::string line; std::string line;

@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "IRCClient.h" #include "IRCClient.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
IRCClient::IRCClient(IRCApplication *app, const std::string& update_channel, const std::string& hostName, unsigned int port, const std::string& callsign, IRCClient::IRCClient(IRCApplication *app, const std::string& update_channel, const std::string& hostName, unsigned int port, const std::string& callsign,
const std::string& password, const std::string& versionInfo, const std::string& localAddr) const std::string& password, const std::string& versionInfo, const std::string& localAddr)
@ -87,7 +88,7 @@ void IRCClient::Entry()
int result = CUtils::getAllIPV4Addresses(m_local_addr, 0, &numAddr, &myaddr, 1); int result = CUtils::getAllIPV4Addresses(m_local_addr, 0, &numAddr, &myaddr, 1);
if (result || 1!=numAddr) { if (result || 1!=numAddr) {
printf("IRCClient::Entry: local address not parseable, using 0.0.0.0\n"); CLog::logInfo("IRCClient::Entry: local address not parseable, using 0.0.0.0\n");
memset(&myaddr, 0, sizeof(struct sockaddr_in)); memset(&myaddr, 0, sizeof(struct sockaddr_in));
} }
@ -98,7 +99,7 @@ void IRCClient::Entry()
switch (state) { switch (state) {
case 0: case 0:
if (m_terminateThread) { if (m_terminateThread) {
printf("IRCClient::Entry: thread terminated at state=%d\n", state); CLog::logInfo("IRCClient::Entry: thread terminated at state=%d\n", state);
return; return;
} }
@ -106,7 +107,7 @@ void IRCClient::Entry()
timer = 30; timer = 30;
if (0 == CUtils::getAllIPV4Addresses(m_host_name, m_port, &numAddr, addr, MAXIPV4ADDR)) { if (0 == CUtils::getAllIPV4Addresses(m_host_name, m_port, &numAddr, addr, MAXIPV4ADDR)) {
printf("IRCClient::Entry: number of DNS entries %d\n", numAddr); CLog::logInfo("IRCClient::Entry: number of DNS entries %d\n", numAddr);
if (numAddr > 0) { if (numAddr > 0) {
currentAddr = 0; currentAddr = 0;
state = 1; state = 1;
@ -118,7 +119,7 @@ void IRCClient::Entry()
case 1: case 1:
if (m_terminateThread) { if (m_terminateThread) {
printf("IRCClient::Entry: thread terminated at state=%d\n", state); CLog::logInfo("IRCClient::Entry: thread terminated at state=%d\n", state);
return; return;
} }
@ -126,12 +127,12 @@ void IRCClient::Entry()
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sock < 0) { if (sock < 0) {
printf("IRCClient::Entry: socket\n"); CLog::logInfo("IRCClient::Entry: socket\n");
timer = 30; timer = 30;
state = 0; state = 0;
} else { } else {
if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) { if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) {
printf("IRCClient::Entry: fcntl\n"); CLog::logInfo("IRCClient::Entry: fcntl\n");
close(sock); close(sock);
timer = 30; timer = 30;
state = 0; state = 0;
@ -139,12 +140,12 @@ void IRCClient::Entry()
unsigned char * h = (unsigned char *) &(myaddr.sin_addr); unsigned char * h = (unsigned char *) &(myaddr.sin_addr);
if (h[0] || h[1] || h[2] || h[3]) if (h[0] || h[1] || h[2] || h[3])
printf("IRCClient::Entry: bind: local address %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]); CLog::logInfo("IRCClient::Entry: bind: local address %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
int res = bind(sock, (struct sockaddr *)&myaddr, sizeof (struct sockaddr_in)); int res = bind(sock, (struct sockaddr *)&myaddr, sizeof (struct sockaddr_in));
if (res) { if (res) {
printf("IRCClient::Entry: bind\n"); CLog::logInfo("IRCClient::Entry: bind\n");
close(sock); close(sock);
state = 0; state = 0;
timer = 30; timer = 30;
@ -152,20 +153,20 @@ void IRCClient::Entry()
} }
h = (unsigned char *) &(addr[currentAddr].sin_addr); h = (unsigned char *) &(addr[currentAddr].sin_addr);
printf("IRCClient::Entry: trying to connect to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]); CLog::logInfo("IRCClient::Entry: trying to connect to %d.%d.%d.%d\n", h[0], h[1], h[2], h[3]);
res = connect(sock, (struct sockaddr *)(addr + currentAddr), sizeof (struct sockaddr_in)); res = connect(sock, (struct sockaddr *)(addr + currentAddr), sizeof (struct sockaddr_in));
if (res == 0) { if (res == 0) {
printf("IRCClient::Entry: connected\n"); CLog::logInfo("IRCClient::Entry: connected\n");
state = 4; state = 4;
} else { } else {
if (errno == EINPROGRESS) { if (errno == EINPROGRESS) {
printf("IRCClient::Entry: connect in progress\n"); CLog::logInfo("IRCClient::Entry: connect in progress\n");
state = 3; state = 3;
timer = 10; // 5 second timeout timer = 10; // 5 second timeout
} else { } else {
printf("IRCClient::Entry: connect\n"); CLog::logInfo("IRCClient::Entry: connect\n");
close(sock); close(sock);
currentAddr++; currentAddr++;
if (currentAddr >= numAddr) { if (currentAddr >= numAddr) {
@ -194,7 +195,7 @@ void IRCClient::Entry()
int res = select(sock+1, NULL, &myset, NULL, &tv); int res = select(sock+1, NULL, &myset, NULL, &tv);
if (res < 0) { if (res < 0) {
printf("IRCClient::Entry: select\n"); CLog::logInfo("IRCClient::Entry: select\n");
close(sock); close(sock);
state = 0; state = 0;
timer = 30; timer = 30;
@ -207,13 +208,13 @@ void IRCClient::Entry()
val_len = sizeof value; val_len = sizeof value;
if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &value, &val_len) < 0) { if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &value, &val_len) < 0) {
printf("IRCClient::Entry: getsockopt\n"); CLog::logInfo("IRCClient::Entry: getsockopt\n");
close(sock); close(sock);
state = 0; state = 0;
timer = 30; timer = 30;
} else { } else {
if (value) { if (value) {
printf("IRCClient::Entry: SO_ERROR=%d\n", value); CLog::logInfo("IRCClient::Entry: SO_ERROR=%d\n", value);
close(sock); close(sock);
currentAddr ++; currentAddr ++;
if (currentAddr >= numAddr) { if (currentAddr >= numAddr) {
@ -224,13 +225,13 @@ void IRCClient::Entry()
timer = 2; timer = 2;
} }
} else { } else {
printf("IRCClient::Entry: connected2\n"); CLog::logInfo("IRCClient::Entry: connected2\n");
state = 4; state = 4;
} }
} }
} }
else if (timer == 0) { // select timeout and timer timeout else if (timer == 0) { // select timeout and timer timeout
printf("IRCClient::Entry: connect timeout\n"); CLog::logInfo("IRCClient::Entry: connect timeout\n");
close(sock); close(sock);
currentAddr ++; currentAddr ++;
if (currentAddr >= numAddr) { if (currentAddr >= numAddr) {
@ -283,12 +284,12 @@ void IRCClient::Entry()
int r = send(sock, buf, len, 0); int r = send(sock, buf, len, 0);
if (r != len) { if (r != len) {
printf("IRCClient::Entry: short write %d < %d\n", r, len); CLog::logInfo("IRCClient::Entry: short write %d < %d\n", r, len);
timer = 0; timer = 0;
state = 6; state = 6;
} }
} else { } else {
printf("IRCClient::Entry: no NL at end, len=%d\n", len); CLog::logInfo("IRCClient::Entry: no NL at end, len=%d\n", len);
timer = 0; timer = 0;
state = 6; state = 6;
} }
@ -316,7 +317,7 @@ void IRCClient::Entry()
close(sock); close(sock);
if (m_terminateThread) { // request to end the thread if (m_terminateThread) { // request to end the thread
printf("IRCClient::Entry: thread terminated at state=%d\n", state); CLog::logInfo("IRCClient::Entry: thread terminated at state=%d\n", state);
return; return;
} }
timer = 30; timer = 30;

@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "IRCDDBApp.h" #include "IRCDDBApp.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
class IRCDDBAppUserObject class IRCDDBAppUserObject
{ {
@ -180,7 +181,7 @@ void IRCDDBApp::rptrQTH(const std::string& callsign, double latitude, double lon
d->moduleQTH[cs] = cs + std::string(" ") + pos + std::string(" ") + d1 + std::string(" ") + d2; d->moduleQTH[cs] = cs + std::string(" ") + pos + std::string(" ") + d1 + std::string(" ") + d2;
printf("QTH: %s\n", d->moduleQTH[cs].c_str()); CLog::logInfo("QTH: %s\n", d->moduleQTH[cs].c_str());
std::string url = infoURL; std::string url = infoURL;
@ -190,7 +191,7 @@ void IRCDDBApp::rptrQTH(const std::string& callsign, double latitude, double lon
if (url.size()) { if (url.size()) {
d->moduleURL[cs] = cs + std::string(" ") + url; d->moduleURL[cs] = cs + std::string(" ") + url;
printf("URL: %s\n", d->moduleURL[cs].c_str()); CLog::logInfo("URL: %s\n", d->moduleURL[cs].c_str());
} }
d->moduleQTHURLMutex.unlock(); d->moduleQTHURLMutex.unlock();
@ -209,7 +210,7 @@ void IRCDDBApp::rptrQRG(const std::string& callsign, double txFrequency, double
d->moduleQRGMutex.lock(); d->moduleQRGMutex.lock();
d->moduleQRG[cs] = cs + std::string(" ") + f; d->moduleQRG[cs] = cs + std::string(" ") + f;
printf("QRG: %s\n", d->moduleQRG[cs].c_str()); CLog::logInfo("QRG: %s\n", d->moduleQRG[cs].c_str());
d->moduleQRGMutex.unlock(); d->moduleQRGMutex.unlock();
d->infoTimer = 5; // send info in 5 seconds d->infoTimer = 5; // send info in 5 seconds
@ -257,7 +258,7 @@ IRCDDB_RESPONSE_TYPE IRCDDBApp::getReplyMessageType()
if (0 == msgType.compare("IDRT_GATEWAY")) if (0 == msgType.compare("IDRT_GATEWAY"))
return IDRT_GATEWAY; return IDRT_GATEWAY;
printf("IRCDDBApp::getMessageType: unknown msg type: %s\n", msgType.c_str()); CLog::logInfo("IRCDDBApp::getMessageType: unknown msg type: %s\n", msgType.c_str());
return IDRT_NONE; return IDRT_NONE;
} }
@ -337,7 +338,7 @@ void IRCDDBApp::userLeave(const std::string& nick)
if (d->currentServer.size()) { if (d->currentServer.size()) {
if (d->user.count(d->myNick) != 1) { if (d->user.count(d->myNick) != 1) {
printf("IRCDDBApp::userLeave: could not find own nick\n"); CLog::logInfo("IRCDDBApp::userLeave: could not find own nick\n");
d->userMapMutex.unlock(); d->userMapMutex.unlock();
return; return;
} }
@ -368,13 +369,13 @@ void IRCDDBApp::userListReset()
void IRCDDBApp::setCurrentNick(const std::string& nick) void IRCDDBApp::setCurrentNick(const std::string& nick)
{ {
d->myNick = nick; d->myNick = nick;
printf("IRCDDBApp::setCurrentNick %s\n", nick.c_str()); CLog::logInfo("IRCDDBApp::setCurrentNick %s\n", nick.c_str());
} }
void IRCDDBApp::setBestServer(const std::string& ircUser) void IRCDDBApp::setBestServer(const std::string& ircUser)
{ {
d->bestServer = ircUser; d->bestServer = ircUser;
printf("IRCDDBApp::setBestServer %s\n", ircUser.c_str()); CLog::logInfo("IRCDDBApp::setBestServer %s\n", ircUser.c_str());
} }
void IRCDDBApp::setTopic(const std::string& topic) void IRCDDBApp::setTopic(const std::string& topic)
@ -667,7 +668,7 @@ void IRCDDBApp::doNotFound(std::string& msg, std::string& retval)
tableID = std::stoi(tk); tableID = std::stoi(tk);
if (tableID<0 || tableID>=numberOfTables) { if (tableID<0 || tableID>=numberOfTables) {
printf("invalid table ID %d\n", tableID); CLog::logInfo("invalid table ID %d\n", tableID);
return; return;
} }
@ -698,7 +699,7 @@ void IRCDDBApp::doUpdate(std::string& msg)
if (std::regex_match(tk, d->tablePattern)) { if (std::regex_match(tk, d->tablePattern)) {
tableID = std::stoi(tk); tableID = std::stoi(tk);
if ((tableID < 0) || (tableID >= numberOfTables)) { if ((tableID < 0) || (tableID >= numberOfTables)) {
printf("invalid table ID %d\n", tableID); CLog::logInfo("invalid table ID %d\n", tableID);
return; return;
} }
@ -899,7 +900,7 @@ void IRCDDBApp::Entry()
break; break;
case 2: // choose server case 2: // choose server
printf("IRCDDBApp: state=2 choose new 's-'-user\n"); CLog::logInfo("IRCDDBApp: state=2 choose new 's-'-user\n");
if (NULL == getSendQ()) if (NULL == getSendQ())
d->state = 10; d->state = 10;
else { else {
@ -925,7 +926,7 @@ void IRCDDBApp::Entry()
if (sendlistTableID < 0) if (sendlistTableID < 0)
d->state = 6; // end of sendlist d->state = 6; // end of sendlist
else { else {
printf("IRCDDBApp: state=3 tableID=%d\n", sendlistTableID); CLog::logInfo("IRCDDBApp: state=3 tableID=%d\n", sendlistTableID);
d->state = 4; // send "SENDLIST" d->state = 4; // send "SENDLIST"
d->timer = 900; // 15 minutes max for update d->timer = 900; // 15 minutes max for update
} }
@ -964,7 +965,7 @@ void IRCDDBApp::Entry()
if (NULL == getSendQ()) if (NULL == getSendQ())
d->state = 10; // disconnect DB d->state = 10; // disconnect DB
else { else {
printf( "IRCDDBApp: state=6 initialization completed\n"); CLog::logInfo( "IRCDDBApp: state=6 initialization completed\n");
d->infoTimer = 2; d->infoTimer = 2;
d->initReady = true; d->initReady = true;
d->state = 7; d->state = 7;

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "IRCClient.h" #include "IRCClient.h"
#include "IRCDDBApp.h" #include "IRCDDBApp.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
struct CIRCDDBClientPrivate struct CIRCDDBClientPrivate
{ {
@ -50,7 +51,7 @@ CIRCDDBClient::~CIRCDDBClient()
// A false return implies a network error, or unable to log in // A false return implies a network error, or unable to log in
bool CIRCDDBClient::open() bool CIRCDDBClient::open()
{ {
printf("start client and app\n"); CLog::logInfo("start client and app\n");
d->client->startWork(); d->client->startWork();
d->app->startWork(); d->app->startWork();
return true; return true;
@ -87,27 +88,27 @@ bool CIRCDDBClient::sendHeard( const std::string& myCall, const std::string& myC
const std::string& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3 ) const std::string& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3 )
{ {
if (myCall.size() != 8) { if (myCall.size() != 8) {
printf("CIRCDDBClient::sendHeard:myCall='%s' len != 8\n", myCall.c_str()); CLog::logInfo("CIRCDDBClient::sendHeard:myCall='%s' len != 8\n", myCall.c_str());
return false; return false;
} }
if (myCallExt.size() != 4) { if (myCallExt.size() != 4) {
printf("CIRCDDBClient::sendHeard:myCallExt='%s' len != 4\n", myCallExt.c_str()); CLog::logInfo("CIRCDDBClient::sendHeard:myCallExt='%s' len != 4\n", myCallExt.c_str());
return false; return false;
} }
if (yourCall.size() != 8) { if (yourCall.size() != 8) {
printf("CIRCDDBClient::sendHeard:yourCall='%s' len != 8\n", yourCall.c_str()); CLog::logInfo("CIRCDDBClient::sendHeard:yourCall='%s' len != 8\n", yourCall.c_str());
return false; return false;
} }
if (rpt1.size() != 8) { if (rpt1.size() != 8) {
printf("CIRCDDBClient::sendHeard:rpt1='%s' len != 8\n", rpt1.c_str()); CLog::logInfo("CIRCDDBClient::sendHeard:rpt1='%s' len != 8\n", rpt1.c_str());
return false; return false;
} }
if (rpt2.size() != 8) { if (rpt2.size() != 8) {
printf("CIRCDDBClient::sendHeard:rpt2='%s' len != 8\n", rpt2.c_str()); CLog::logInfo("CIRCDDBClient::sendHeard:rpt2='%s' len != 8\n", rpt2.c_str());
return false; return false;
} }
@ -116,10 +117,10 @@ bool CIRCDDBClient::sendHeard( const std::string& myCall, const std::string& myC
void CIRCDDBClient::sendDStarGatewayInfo(const std::string subcommand, const std::vector<std::string> parms) void CIRCDDBClient::sendDStarGatewayInfo(const std::string subcommand, const std::vector<std::string> parms)
{ {
printf("CIRCDDBClient::sendDStarGatewayInfo subcommand %s parms", subcommand.c_str()); CLog::logInfo("CIRCDDBClient::sendDStarGatewayInfo subcommand %s parms", subcommand.c_str());
for(unsigned int i=0; i < parms.size();i++) for(unsigned int i=0; i < parms.size();i++)
printf(" %s", parms[i].c_str()); CLog::logInfo(" %s", parms[i].c_str());
printf("\n"); CLog::logInfo("\n");
if(m_isQuadNet) { if(m_isQuadNet) {
d->app->sendDStarGatewayInfo(subcommand, parms); d->app->sendDStarGatewayInfo(subcommand, parms);
@ -131,27 +132,27 @@ bool CIRCDDBClient::sendHeardWithTXMsg(const std::string& myCall, const std::str
const std::string& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3, const std::string& network_destination, const std::string& tx_message) const std::string& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3, const std::string& network_destination, const std::string& tx_message)
{ {
if (myCall.size() != 8) { if (myCall.size() != 8) {
printf("CIRCDDBClient::sendHeardWithTXMsg:myCall='%s' len != 8\n", myCall.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXMsg:myCall='%s' len != 8\n", myCall.c_str());
return false; return false;
} }
if (myCallExt.size() != 4) { if (myCallExt.size() != 4) {
printf("CIRCDDBClient::sendHeardWithTXMsg:myCallExt='%s' len != 4\n", myCallExt.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXMsg:myCallExt='%s' len != 4\n", myCallExt.c_str());
return false; return false;
} }
if (yourCall.size() != 8) { if (yourCall.size() != 8) {
printf("CIRCDDBClient::sendHeardWithTXMsg:yourCall='%s' len != 8\n", yourCall.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXMsg:yourCall='%s' len != 8\n", yourCall.c_str());
return false; return false;
} }
if (rpt1.size() != 8) { if (rpt1.size() != 8) {
printf("CIRCDDBClient::sendHeardWithTXMsg:rpt1='%s' len != 8\n", rpt1.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXMsg:rpt1='%s' len != 8\n", rpt1.c_str());
return false; return false;
} }
if (rpt2.size() != 8) { if (rpt2.size() != 8) {
printf("CIRCDDBClient::sendHeardWithTXMsg:rpt2='%s' len != 8\n", rpt2.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXMsg:rpt2='%s' len != 8\n", rpt2.c_str());
return false; return false;
} }
@ -160,7 +161,7 @@ bool CIRCDDBClient::sendHeardWithTXMsg(const std::string& myCall, const std::str
dest = std::string(" "); dest = std::string(" ");
if (8 != dest.size()) { if (8 != dest.size()) {
printf("CIRCDDBClient::sendHeardWithTXMsg:network_destination='%s' len != 8\n", dest.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXMsg:network_destination='%s' len != 8\n", dest.c_str());
return false; return false;
} }
@ -183,42 +184,42 @@ bool CIRCDDBClient::sendHeardWithTXStats( const std::string& myCall, const std::
const std::string& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3, int num_dv_frames, int num_dv_silent_frames, int num_bit_errors) const std::string& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3, int num_dv_frames, int num_dv_silent_frames, int num_bit_errors)
{ {
if ((num_dv_frames <= 0) || (num_dv_frames > 65535)) { if ((num_dv_frames <= 0) || (num_dv_frames > 65535)) {
printf("CIRCDDBClient::sendHeardWithTXStats:num_dv_frames=%d not in range 1-65535\n", num_dv_frames); CLog::logInfo("CIRCDDBClient::sendHeardWithTXStats:num_dv_frames=%d not in range 1-65535\n", num_dv_frames);
return false; return false;
} }
if (num_dv_silent_frames > num_dv_frames) { if (num_dv_silent_frames > num_dv_frames) {
printf("CIRCDDBClient::sendHeardWithTXStats:num_dv_silent_frames=%d > num_dv_frames=%d\n", num_dv_silent_frames, num_dv_frames); CLog::logInfo("CIRCDDBClient::sendHeardWithTXStats:num_dv_silent_frames=%d > num_dv_frames=%d\n", num_dv_silent_frames, num_dv_frames);
return false; return false;
} }
if (num_bit_errors > (4*num_dv_frames)) { // max 4 bit errors per frame if (num_bit_errors > (4*num_dv_frames)) { // max 4 bit errors per frame
printf("CIRCDDBClient::sendHeardWithTXStats:num_bit_errors > (4*num_dv_frames), %d > 4*%d\n", num_bit_errors, num_dv_frames); CLog::logInfo("CIRCDDBClient::sendHeardWithTXStats:num_bit_errors > (4*num_dv_frames), %d > 4*%d\n", num_bit_errors, num_dv_frames);
return false; return false;
} }
if (myCall.size() != 8) { if (myCall.size() != 8) {
printf("CIRCDDBClient::sendHeardWithTXStats:myCall='%s' len != 8\n", myCall.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXStats:myCall='%s' len != 8\n", myCall.c_str());
return false; return false;
} }
if (myCallExt.size() != 4) { if (myCallExt.size() != 4) {
printf("CIRCDDBClient::sendHeardWithTXStats:myCallExt='%s' len != 4\n", myCallExt.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXStats:myCallExt='%s' len != 4\n", myCallExt.c_str());
return false; return false;
} }
if (yourCall.size() != 8) { if (yourCall.size() != 8) {
printf("CIRCDDBClient::sendHeardWithTXStats:yourCall='%s' len != 8\n", yourCall.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXStats:yourCall='%s' len != 8\n", yourCall.c_str());
return false; return false;
} }
if (rpt1.size() != 8) { if (rpt1.size() != 8) {
printf("CIRCDDBClient::sendHeardWithTXStats:rpt1='%s' len != 8\n", rpt1.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXStats:rpt1='%s' len != 8\n", rpt1.c_str());
return false; return false;
} }
if (rpt2.size() != 8) { if (rpt2.size() != 8) {
printf("CIRCDDBClient::sendHeardWithTXStats:rpt2='%s' len != 8\n", rpt2.c_str()); CLog::logInfo("CIRCDDBClient::sendHeardWithTXStats:rpt2='%s' len != 8\n", rpt2.c_str());
return false; return false;
} }
@ -244,7 +245,7 @@ bool CIRCDDBClient::sendHeardWithTXStats( const std::string& myCall, const std::
bool CIRCDDBClient::findGateway(const std::string& gatewayCallsign) bool CIRCDDBClient::findGateway(const std::string& gatewayCallsign)
{ {
if (8 != gatewayCallsign.size()) { if (8 != gatewayCallsign.size()) {
printf("CIRCDDBClient::findGateway:gatewayCallsign='%s' len != 8\n", gatewayCallsign.c_str()); CLog::logInfo("CIRCDDBClient::findGateway:gatewayCallsign='%s' len != 8\n", gatewayCallsign.c_str());
return false; return false;
} }
std::string gw(gatewayCallsign); std::string gw(gatewayCallsign);
@ -256,7 +257,7 @@ bool CIRCDDBClient::findGateway(const std::string& gatewayCallsign)
bool CIRCDDBClient::findRepeater(const std::string& repeaterCallsign) bool CIRCDDBClient::findRepeater(const std::string& repeaterCallsign)
{ {
if (8 != repeaterCallsign.size()) { if (8 != repeaterCallsign.size()) {
printf("CIRCDDBClient::findRepeater:repeaterCallsign='%s' len != 8\n", repeaterCallsign.c_str()); CLog::logInfo("CIRCDDBClient::findRepeater:repeaterCallsign='%s' len != 8\n", repeaterCallsign.c_str());
return false; return false;
} }
std::string rptr(repeaterCallsign); std::string rptr(repeaterCallsign);
@ -268,7 +269,7 @@ bool CIRCDDBClient::findRepeater(const std::string& repeaterCallsign)
bool CIRCDDBClient::findUser(const std::string& userCallsign) bool CIRCDDBClient::findUser(const std::string& userCallsign)
{ {
if (8 != userCallsign.size()) { if (8 != userCallsign.size()) {
printf("CIRCDDBClient::findUser:userCall='%s' len != 8\n", userCallsign.c_str()); CLog::logInfo("CIRCDDBClient::findUser:userCall='%s' len != 8\n", userCallsign.c_str());
return false; return false;
} }
std::string usr(userCallsign); std::string usr(userCallsign);
@ -291,24 +292,24 @@ bool CIRCDDBClient::receiveRepeater(std::string& repeaterCallsign, std::string&
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType(); IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_REPEATER) { if (rt != IDRT_REPEATER) {
printf("CIRCDDBClient::receiveRepeater: unexpected response type=%d\n", rt); CLog::logInfo("CIRCDDBClient::receiveRepeater: unexpected response type=%d\n", rt);
return false; return false;
} }
IRCMessage *m = d->app->getReplyMessage(); IRCMessage *m = d->app->getReplyMessage();
if (m == NULL) { if (m == NULL) {
printf("CIRCDDBClient::receiveRepeater: no message\n"); CLog::logInfo("CIRCDDBClient::receiveRepeater: no message\n");
return false; return false;
} }
if (m->getCommand().compare("IDRT_REPEATER")) { if (m->getCommand().compare("IDRT_REPEATER")) {
printf("CIRCDDBClient::receiveRepeater: wrong message type, expected 'IDRT_REPEATER, got '%s'\n", m->getCommand().c_str()); CLog::logInfo("CIRCDDBClient::receiveRepeater: wrong message type, expected 'IDRT_REPEATER, got '%s'\n", m->getCommand().c_str());
delete m; delete m;
return false; return false;
} }
if (3 != m->getParamCount()) { if (3 != m->getParamCount()) {
printf("CIRCDDBClient::receiveRepeater: unexpected number of message parameters, expected 3, got %d\n", m->getParamCount()); CLog::logInfo("CIRCDDBClient::receiveRepeater: unexpected number of message parameters, expected 3, got %d\n", m->getParamCount());
delete m; delete m;
return false; return false;
} }
@ -327,25 +328,25 @@ bool CIRCDDBClient::receiveGateway(std::string& gatewayCallsign, std::string& ad
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType(); IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_GATEWAY) { if (rt != IDRT_GATEWAY) {
printf("CIRCDDBClient::receiveGateway: unexpected response type=%d\n", rt); CLog::logInfo("CIRCDDBClient::receiveGateway: unexpected response type=%d\n", rt);
return false; return false;
} }
IRCMessage *m = d->app->getReplyMessage(); IRCMessage *m = d->app->getReplyMessage();
if (m == NULL) { if (m == NULL) {
printf("CIRCDDBClient::receiveGateway: no message\n"); CLog::logInfo("CIRCDDBClient::receiveGateway: no message\n");
return false; return false;
} }
if (m->getCommand().compare("IDRT_GATEWAY")) { if (m->getCommand().compare("IDRT_GATEWAY")) {
printf("CIRCDDBClient::receiveGateway: wrong message type, expected 'IDRT_GATEWAY' got '%s'\n", m->getCommand().c_str()); CLog::logInfo("CIRCDDBClient::receiveGateway: wrong message type, expected 'IDRT_GATEWAY' got '%s'\n", m->getCommand().c_str());
delete m; delete m;
return false; return false;
} }
if (2 != m->getParamCount()) { if (2 != m->getParamCount()) {
printf("CIRCDDBClient::receiveGateway: unexpected number of message parameters, expected 2, got %d\n", m->getParamCount()); CLog::logInfo("CIRCDDBClient::receiveGateway: unexpected number of message parameters, expected 2, got %d\n", m->getParamCount());
delete m; delete m;
return false; return false;
} }
@ -369,25 +370,25 @@ bool CIRCDDBClient::receiveUser(std::string& userCallsign, std::string& repeater
IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType(); IRCDDB_RESPONSE_TYPE rt = d->app->getReplyMessageType();
if (rt != IDRT_USER) { if (rt != IDRT_USER) {
printf("CIRCDDBClient::receiveUser: unexpected response type=%d\n", rt); CLog::logInfo("CIRCDDBClient::receiveUser: unexpected response type=%d\n", rt);
return false; return false;
} }
IRCMessage * m = d->app->getReplyMessage(); IRCMessage * m = d->app->getReplyMessage();
if (m == NULL) { if (m == NULL) {
printf("CIRCDDBClient::receiveUser: no message\n"); CLog::logInfo("CIRCDDBClient::receiveUser: no message\n");
return false; return false;
} }
if (m->getCommand().compare("IDRT_USER")) { if (m->getCommand().compare("IDRT_USER")) {
printf("CIRCDDBClient::receiveUser: wrong message type, expected 'IDRT_USER', got '%s'\n", m->getCommand().c_str()); CLog::logInfo("CIRCDDBClient::receiveUser: wrong message type, expected 'IDRT_USER', got '%s'\n", m->getCommand().c_str());
delete m; delete m;
return false; return false;
} }
if (5 != m->getParamCount()) { if (5 != m->getParamCount()) {
printf("CIRCDDBClient::receiveUser: unexpected number of message parameters, expected 5, got %d\n", m->getParamCount()); CLog::logInfo("CIRCDDBClient::receiveUser: unexpected number of message parameters, expected 5, got %d\n", m->getParamCount());
delete m; delete m;
return false; return false;
} }

@ -20,9 +20,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "IRCDDBMultiClient.h"
#include <stdio.h> #include <stdio.h>
#include "IRCDDBMultiClient.h"
#include "Log.h"
CIRCDDBMultiClient::CIRCDDBMultiClient(const CIRCDDB_Array& clients) : CIRCDDBMultiClient::CIRCDDBMultiClient(const CIRCDDB_Array& clients) :
m_clients(), m_clients(),
m_queriesLock(), m_queriesLock(),
@ -284,11 +287,11 @@ bool CIRCDDBMultiClient::receiveUser(std::string & userCallsign, std::string & r
{ {
CIRCDDBMultiClientQuery * item = checkAndGetNextResponse(IDRT_USER, "CIRCDDBMultiClient::receiveUser: unexpected response type"); CIRCDDBMultiClientQuery * item = checkAndGetNextResponse(IDRT_USER, "CIRCDDBMultiClient::receiveUser: unexpected response type");
if (item == NULL) { if (item == NULL) {
//wxLogMessage(wxT("CIRCDDBMultiClient::receiveUser NO USER IN QUEUE")); //CLog::logInfo(wxT("CIRCDDBMultiClient::receiveUser NO USER IN QUEUE"));
return false; return false;
} }
//wxLogMessage(wxT("CIRCDDBMultiClient::receiveUser : %s"), item->toString()); //CLog::logInfo(wxT("CIRCDDBMultiClient::receiveUser : %s"), item->toString());
userCallsign = item->getUser(); userCallsign = item->getUser();
repeaterCallsign = item->getRepeater(); repeaterCallsign = item->getRepeater();
@ -312,7 +315,7 @@ CIRCDDBMultiClientQuery * CIRCDDBMultiClient::checkAndGetNextResponse(IRCDDB_RES
m_responseQueueLock.lock(); m_responseQueueLock.lock();
if (m_responseQueue.size() == 0 || m_responseQueue[0]->getType() != expectedType) { if (m_responseQueue.size() == 0 || m_responseQueue[0]->getType() != expectedType) {
printf(errorMessage.c_str()); CLog::logInfo(errorMessage.c_str());
} }
else { else {
item = m_responseQueue[0]; item = m_responseQueue[0];

@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "IRCProtocol.h" #include "IRCProtocol.h"
#include "Utils.h" #include "Utils.h"
#include "IRCDDBMultiClient.h"
#include "Log.h"
#define CIRCDDB_VERSION "2.0.0" #define CIRCDDB_VERSION "2.0.0"
@ -74,7 +76,7 @@ void IRCProtocol::setNetworkReady(bool b)
{ {
if (b == true) { if (b == true) {
if (0 != m_state) if (0 != m_state)
printf("IRCProtocol::setNetworkReady: unexpected state\n"); CLog::logInfo("IRCProtocol::setNetworkReady: unexpected state\n");
m_state = 1; m_state = 1;
chooseNewNick(); chooseNewNick();
} else } else

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "IRCReceiver.h" #include "IRCReceiver.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
IRCReceiver::IRCReceiver(int sock, IRCMessageQueue *q) IRCReceiver::IRCReceiver(int sock, IRCMessageQueue *q)
{ {
@ -62,21 +63,21 @@ static int doRead(int sock, char *buf, int buf_size)
int res = select(sock+1, &rdset, NULL, &errset, &tv); int res = select(sock+1, &rdset, NULL, &errset, &tv);
if (res < 0) { if (res < 0) {
printf("IRCReceiver::doRead: select\n"); CLog::logInfo("IRCReceiver::doRead: select\n");
return -1; return -1;
} else if (res > 0) { } else if (res > 0) {
if (FD_ISSET(sock, &errset)) { if (FD_ISSET(sock, &errset)) {
printf("IRCReceiver::doRead: select (FD_ISSET(sock, exceptfds))\n"); CLog::logInfo("IRCReceiver::doRead: select (FD_ISSET(sock, exceptfds))\n");
return -1; return -1;
} }
if (FD_ISSET(sock, &rdset)) { if (FD_ISSET(sock, &rdset)) {
res = recv(sock, buf, buf_size, 0); res = recv(sock, buf, buf_size, 0);
if (res < 0) { if (res < 0) {
printf("IRCReceiver::doRead: read\n"); CLog::logInfo("IRCReceiver::doRead: read\n");
return -1; return -1;
} else if (res == 0) { } else if (res == 0) {
printf("IRCReceiver::doRead: EOF read==0\n"); CLog::logInfo("IRCReceiver::doRead: EOF read==0\n");
return -1; return -1;
} else } else
return res; return res;

@ -112,7 +112,7 @@ bool CIcomRepeaterProtocolHandler::open()
if (length == 10 && m_buffer[0U] == 'I' && m_buffer[1U] == 'N' && m_buffer[2U] == 'I' && m_buffer[3U] == 'T' && m_buffer[6U] == 0x72 && m_buffer[7U] == 0x00) { if (length == 10 && m_buffer[0U] == 'I' && m_buffer[1U] == 'N' && m_buffer[2U] == 'I' && m_buffer[3U] == 'T' && m_buffer[6U] == 0x72 && m_buffer[7U] == 0x00) {
m_seqNo = m_buffer[4U] * 256U + m_buffer[5U] + 1U; m_seqNo = m_buffer[4U] * 256U + m_buffer[5U] + 1U;
wxLogMessage("Initial sequence number from the RP2C is %u", m_seqNo); CLog::logInfo("Initial sequence number from the RP2C is %u", m_seqNo);
// Start the thread // Start the thread
Create(); Create();
@ -126,14 +126,14 @@ bool CIcomRepeaterProtocolHandler::open()
m_socket.close(); m_socket.close();
wxLogError("No reply from the RP2C for 10 seconds, aborting"); CLog::logError("No reply from the RP2C for 10 seconds, aborting");
return false; return false;
} }
void* CIcomRepeaterProtocolHandler::Entry() void* CIcomRepeaterProtocolHandler::Entry()
{ {
wxLogMessage("Starting the Icom Controller thread"); CLog::logInfo("Starting the Icom Controller thread");
try { try {
while (!m_killed) { while (!m_killed) {
@ -148,13 +148,13 @@ void* CIcomRepeaterProtocolHandler::Entry()
} }
catch (std::exception& e) { catch (std::exception& e) {
std::string message(e.what()); std::string message(e.what());
wxLogError("Exception raised in the Icom Controller thread - \"%s\"", message.c_str()); CLog::logError("Exception raised in the Icom Controller thread - \"%s\"", message.c_str());
} }
catch (...) { catch (...) {
wxLogError("Unknown exception raised in the Icom Controller thread"); CLog::logError("Unknown exception raised in the Icom Controller thread");
} }
wxLogMessage("Stopping the Icom Controller thread"); CLog::logInfo("Stopping the Icom Controller thread");
m_socket.close(); m_socket.close();
@ -209,7 +209,7 @@ void CIcomRepeaterProtocolHandler::readIcomPackets()
return; return;
if (address.s_addr != m_icomAddress.s_addr || port != m_icomPort) { if (address.s_addr != m_icomAddress.s_addr || port != m_icomPort) {
wxLogError("Incoming Icom data from an unknown source"); CLog::logError("Incoming Icom data from an unknown source");
continue; continue;
} }
@ -247,7 +247,7 @@ void CIcomRepeaterProtocolHandler::readIcomPackets()
CHeardData* heard = new CHeardData; CHeardData* heard = new CHeardData;
bool ret = heard->setIcomRepeaterData(m_buffer, length, m_icomAddress, m_icomPort); bool ret = heard->setIcomRepeaterData(m_buffer, length, m_icomAddress, m_icomPort);
if (!ret) { if (!ret) {
wxLogError("Invalid heard data from the RP2C"); CLog::logError("Invalid heard data from the RP2C");
delete heard; delete heard;
continue; continue;
} }
@ -267,7 +267,7 @@ void CIcomRepeaterProtocolHandler::readIcomPackets()
CDDData* data = new CDDData; CDDData* data = new CDDData;
bool ret = data->setIcomRepeaterData(m_buffer, length, m_icomAddress, m_icomPort); bool ret = data->setIcomRepeaterData(m_buffer, length, m_icomAddress, m_icomPort);
if (!ret) { if (!ret) {
wxLogError("Invalid DD data from the RP2C"); CLog::logError("Invalid DD data from the RP2C");
delete data; delete data;
continue; continue;
} }
@ -282,7 +282,7 @@ void CIcomRepeaterProtocolHandler::readIcomPackets()
CHeaderData* header = new CHeaderData; CHeaderData* header = new CHeaderData;
bool ret = header->setIcomRepeaterData(m_buffer, length, true, m_icomAddress, m_icomPort); bool ret = header->setIcomRepeaterData(m_buffer, length, true, m_icomAddress, m_icomPort);
if (!ret) { if (!ret) {
wxLogError("Invalid header data or checksum from the RP2C"); CLog::logError("Invalid header data or checksum from the RP2C");
delete header; delete header;
continue; continue;
} }
@ -298,7 +298,7 @@ void CIcomRepeaterProtocolHandler::readIcomPackets()
CAMBEData* data = new CAMBEData; CAMBEData* data = new CAMBEData;
bool ret = data->setIcomRepeaterData(m_buffer, length, m_icomAddress, m_icomPort); bool ret = data->setIcomRepeaterData(m_buffer, length, m_icomAddress, m_icomPort);
if (!ret) { if (!ret) {
wxLogError("Invalid AMBE data from the RP2C"); CLog::logError("Invalid AMBE data from the RP2C");
delete data; delete data;
continue; continue;
} }
@ -325,7 +325,7 @@ void CIcomRepeaterProtocolHandler::sendGwyPackets()
if (m_ackQueue == NULL) { if (m_ackQueue == NULL) {
m_ackQueue = m_gwyQueue.getData(); m_ackQueue = m_gwyQueue.getData();
if (m_ackQueue == NULL) { if (m_ackQueue == NULL) {
wxLogError("getData of a non-empty gateway queue is NULL"); CLog::logError("getData of a non-empty gateway queue is NULL");
return; return;
} }
} }
@ -355,7 +355,7 @@ void CIcomRepeaterProtocolHandler::sendGwyPackets()
break; break;
default: default:
wxLogError("Invalid type in the gateway queue"); CLog::logError("Invalid type in the gateway queue");
break; break;
} }
@ -366,7 +366,7 @@ void CIcomRepeaterProtocolHandler::sendGwyPackets()
m_retryTimer.start(); m_retryTimer.start();
if (m_tries > 0U && (m_tries % 100U) == 0U) if (m_tries > 0U && (m_tries % 100U) == 0U)
wxLogMessage("No reply from the RP2C after %u retries", m_tries); CLog::logInfo("No reply from the RP2C after %u retries", m_tries);
} }
} }
@ -377,7 +377,7 @@ REPEATER_TYPE CIcomRepeaterProtocolHandler::read()
} else { } else {
CDataQueue* dq = m_rptrQueue.peek(); CDataQueue* dq = m_rptrQueue.peek();
if (dq == NULL) { if (dq == NULL) {
wxLogError("Peek of a non-empty repeater queue is NULL"); CLog::logError("Peek of a non-empty repeater queue is NULL");
m_type = RT_NONE; m_type = RT_NONE;
} else { } else {
m_type = dq->getType(); m_type = dq->getType();
@ -394,12 +394,12 @@ CPollData* CIcomRepeaterProtocolHandler::readPoll()
CDataQueue* dq = m_rptrQueue.getData(); CDataQueue* dq = m_rptrQueue.getData();
if (dq == NULL) { if (dq == NULL) {
wxLogError("Missing DataQueue in readPoll"); CLog::logError("Missing DataQueue in readPoll");
return NULL; return NULL;
} }
if (dq->getType() != RT_POLL) { if (dq->getType() != RT_POLL) {
wxLogError("Wrong DataQueue type in readPoll"); CLog::logError("Wrong DataQueue type in readPoll");
delete dq; delete dq;
return NULL; return NULL;
} }
@ -419,12 +419,12 @@ CHeaderData* CIcomRepeaterProtocolHandler::readHeader()
CDataQueue* dq = m_rptrQueue.getData(); CDataQueue* dq = m_rptrQueue.getData();
if (dq == NULL) { if (dq == NULL) {
wxLogError("Missing DataQueue in readHeader"); CLog::logError("Missing DataQueue in readHeader");
return NULL; return NULL;
} }
if (dq->getType() != RT_HEADER) { if (dq->getType() != RT_HEADER) {
wxLogError("Wrong DataQueue type in readHeader"); CLog::logError("Wrong DataQueue type in readHeader");
delete dq; delete dq;
return NULL; return NULL;
} }
@ -443,12 +443,12 @@ CAMBEData* CIcomRepeaterProtocolHandler::readAMBE()
CDataQueue* dq = m_rptrQueue.getData(); CDataQueue* dq = m_rptrQueue.getData();
if (dq == NULL) { if (dq == NULL) {
wxLogError("Missing DataQueue in readData"); CLog::logError("Missing DataQueue in readData");
return NULL; return NULL;
} }
if (dq->getType() != RT_AMBE) { if (dq->getType() != RT_AMBE) {
wxLogError("Wrong DataQueue type in readData"); CLog::logError("Wrong DataQueue type in readData");
delete dq; delete dq;
return NULL; return NULL;
} }
@ -467,12 +467,12 @@ CHeardData* CIcomRepeaterProtocolHandler::readHeard()
CDataQueue* dq = m_rptrQueue.getData(); CDataQueue* dq = m_rptrQueue.getData();
if (dq == NULL) { if (dq == NULL) {
wxLogError("Missing DataQueue in readHeard"); CLog::logError("Missing DataQueue in readHeard");
return NULL; return NULL;
} }
if (dq->getType() != RT_HEARD) { if (dq->getType() != RT_HEARD) {
wxLogError("Wrong DataQueue type in readHeard"); CLog::logError("Wrong DataQueue type in readHeard");
delete dq; delete dq;
return NULL; return NULL;
} }
@ -491,12 +491,12 @@ CDDData* CIcomRepeaterProtocolHandler::readDD()
CDataQueue* dq = m_rptrQueue.getData(); CDataQueue* dq = m_rptrQueue.getData();
if (dq == NULL) { if (dq == NULL) {
wxLogError("Missing DataQueue in readData"); CLog::logError("Missing DataQueue in readData");
return NULL; return NULL;
} }
if (dq->getType() != RT_DD) { if (dq->getType() != RT_DD) {
wxLogError("Wrong DataQueue type in readData"); CLog::logError("Wrong DataQueue type in readData");
delete dq; delete dq;
return NULL; return NULL;
} }

@ -0,0 +1,42 @@
/*
* Copyright (c) 2021 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <ctime>
#include "Log.h"
LOG_SEVERITY CLog::m_level = LS_INFO;
std::string CLog::m_file = "";
bool CLog::m_logToConsole = true;
void CLog::initialize(const std::string& logfile, LOG_SEVERITY logLevel, bool logToConsole)
{
m_file = logfile;
m_level = logLevel;
m_logToConsole = logToConsole;
}
void CLog::getTimeStamp(std::string & s)
{
std::time_t now= std::time(0);
std::tm* now_tm= std::gmtime(&now);
char buf[64];
std::strftime(buf, 42, "%Y-%m-%d %T", now_tm);
s = std::string(buf);
}

110
Log.h

@ -16,13 +16,109 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/*
* A Dummy wxLog replacement to speed up conversion
*/
#pragma once #pragma once
#define wxLogMessage(...) ::printf(__VA_ARGS__) #include <string>
#define wxLogError(...) ::printf(__VA_ARGS__) #include <iostream>
#define wxLogWarning(...) ::printf(__VA_ARGS__) #include <fstream>
#define wxLogInfo(...) ::printf(__VA_ARGS__) #include <chrono>
#include <sstream>
#include <boost/algorithm/string.hpp>
#include "StringUtils.h"
enum LOG_SEVERITY {
LS_TRACE = 1,
LS_DEBUG,
LS_INFO,
LS_WARNING,
LS_ERROR,
LS_FATAL
};
class CLog
{
private:
static LOG_SEVERITY m_level;
static std::string m_file;
static bool m_logToConsole;
static void getTimeStamp(std::string & s);
public:
static void initialize(const std::string& logfile, LOG_SEVERITY logLevel, bool logToConsole);
template<typename... Args> static void logDebug(const std::string & f, Args... args)
{
log(LS_DEBUG, f, args...);
}
template<typename... Args> static void logInfo(const std::string & f, Args... args)
{
log(LS_INFO, f, args...);
}
template<typename... Args> static void logWarning(const std::string & f, Args... args)
{
log(LS_WARNING, f, args...);
}
template<typename... Args> static void logError(const std::string & f, Args... args)
{
log(LS_ERROR, f, args...);
}
template<typename... Args> static void logFatal(const std::string & f, Args... args)
{
log(LS_FATAL, f, args...);
}
template<typename... Args> static void log(LOG_SEVERITY severity, const std::string & f, Args... args)
{
if(severity >= CLog::m_level || CLog::m_file.empty()) {
std::string severityStr;
switch (severity)
{
case LS_DEBUG:
severityStr = "DEBUG ";
break;
case LS_ERROR:
severityStr = "ERROR ";
break;
case LS_FATAL:
severityStr = "FATAL ";
break;
case LS_INFO :
severityStr = "INFO ";
break;
case LS_WARNING:
severityStr = "WARNING";
break;
case LS_TRACE:
severityStr = "TRACE ";
break;
default:
break;
}
std::string message = CStringUtils::string_format(f, args...);
boost::trim(message);
std::string timeUtc;
getTimeStamp(timeUtc);
std::stringstream s;
s << "[" << timeUtc << "] [" << severityStr << "] " << message << std::endl;
if(CLog::m_logToConsole || CLog::m_file.empty())
std::cout << s.str();
std::ofstream file;
file.open(CLog::m_file, std::ios::app);
if(file.is_open()) {
file << s.str();
file.close();
}
}
}
};

@ -55,7 +55,7 @@ void CRemoteHandler::process()
switch (type) { switch (type) {
case RPHT_LOGOUT: case RPHT_LOGOUT:
m_handler.setLoggedIn(false); m_handler.setLoggedIn(false);
wxLogMessage("Remote control user has logged out"); CLog::logInfo("Remote control user has logged out");
break; break;
case RPHT_LOGIN: case RPHT_LOGIN:
m_random = ::rand(); m_random = ::rand();
@ -64,11 +64,11 @@ void CRemoteHandler::process()
case RPHT_HASH: { case RPHT_HASH: {
bool valid = m_handler.readHash(m_password, m_random); bool valid = m_handler.readHash(m_password, m_random);
if (valid) { if (valid) {
wxLogMessage("Remote control user has logged in"); CLog::logInfo("Remote control user has logged in");
m_handler.setLoggedIn(true); m_handler.setLoggedIn(true);
m_handler.sendACK(); m_handler.sendACK();
} else { } else {
wxLogMessage("Remote control user has failed login authentication"); CLog::logInfo("Remote control user has failed login authentication");
m_handler.setLoggedIn(false); m_handler.setLoggedIn(false);
m_handler.sendNAK("Invalid password"); m_handler.sendNAK("Invalid password");
} }
@ -94,9 +94,9 @@ void CRemoteHandler::process()
RECONNECT reconnect; RECONNECT reconnect;
m_handler.readLink(callsign, reconnect, reflector); m_handler.readLink(callsign, reconnect, reflector);
if (reflector.empty()) if (reflector.empty())
wxLogMessage("Remote control user has linked \"%s\" to \"None\" with reconnect %d", callsign.c_str(), int(reconnect)); CLog::logInfo("Remote control user has linked \"%s\" to \"None\" with reconnect %d", callsign.c_str(), int(reconnect));
else else
wxLogMessage("Remote control user has linked \"%s\" to \"%s\" with reconnect %d", callsign.c_str(), reflector.c_str(), int(reconnect)); CLog::logInfo("Remote control user has linked \"%s\" to \"%s\" with reconnect %d", callsign.c_str(), reflector.c_str(), int(reconnect));
link(callsign, reconnect, reflector, true); link(callsign, reconnect, reflector, true);
} }
break; break;
@ -104,7 +104,7 @@ void CRemoteHandler::process()
std::string callsign, reflector; std::string callsign, reflector;
PROTOCOL protocol; PROTOCOL protocol;
m_handler.readUnlink(callsign, protocol, reflector); m_handler.readUnlink(callsign, protocol, reflector);
wxLogMessage("Remote control user has unlinked \"%s\" from \"%s\" for protocol %d", callsign.c_str(), reflector.c_str(), int(protocol)); CLog::logInfo("Remote control user has unlinked \"%s\" from \"%s\" for protocol %d", callsign.c_str(), reflector.c_str(), int(protocol));
unlink(callsign, protocol, reflector); unlink(callsign, protocol, reflector);
} }
break; break;
@ -113,9 +113,9 @@ void CRemoteHandler::process()
RECONNECT reconnect; RECONNECT reconnect;
m_handler.readLinkScr(callsign, reconnect, reflector); m_handler.readLinkScr(callsign, reconnect, reflector);
if (reflector.empty()) if (reflector.empty())
wxLogMessage("Remote control user has linked \"%s\" to \"None\" with reconnect %d from localhost", callsign.c_str(), reconnect); CLog::logInfo("Remote control user has linked \"%s\" to \"None\" with reconnect %d from localhost", callsign.c_str(), reconnect);
else else
wxLogMessage("Remote control user has linked \"%s\" to \"%s\" with reconnect %d from localhost", callsign.c_str(), reflector.c_str(), reconnect); CLog::logInfo("Remote control user has linked \"%s\" to \"%s\" with reconnect %d from localhost", callsign.c_str(), reflector.c_str(), reconnect);
link(callsign, reconnect, reflector, false); link(callsign, reconnect, reflector, false);
} }
break; break;
@ -123,7 +123,7 @@ void CRemoteHandler::process()
case RPHT_LOGOFF: { case RPHT_LOGOFF: {
std::string callsign, user; std::string callsign, user;
m_handler.readLogoff(callsign, user); m_handler.readLogoff(callsign, user);
wxLogMessage("Remote control user has logged off \"%s\" from \"%s\"", user.c_str(), callsign.c_str()); CLog::logInfo("Remote control user has logged off \"%s\" from \"%s\"", user.c_str(), callsign.c_str());
logoff(callsign, user); logoff(callsign, user);
} }
break; break;

@ -295,7 +295,7 @@ void CRepeaterHandler::add(const std::string& callsign, const std::string& band,
} }
} }
wxLogError("Cannot add repeater with callsign %s, no space", callsign.c_str()); CLog::logError("Cannot add repeater with callsign %s, no space", callsign.c_str());
delete repeater; delete repeater;
} }
@ -589,12 +589,12 @@ void CRepeaterHandler::processRepeater(CHeaderData& header)
m_band1 = band1; m_band1 = band1;
m_band2 = band2; m_band2 = band2;
m_band3 = band3; m_band3 = band3;
wxLogMessage("Repeater %s registered with bands %u %u %u", m_rptCall1.c_str(), m_band1, m_band2, m_band3); CLog::logInfo("Repeater %s registered with bands %u %u %u", m_rptCall1.c_str(), m_band1, m_band2, m_band3);
} }
} }
if (m_flag1 == 0x01) { if (m_flag1 == 0x01) {
wxLogMessage("Received a busy message from repeater %s", m_rptCall1.c_str()); CLog::logInfo("Received a busy message from repeater %s", m_rptCall1.c_str());
return; return;
} }
@ -690,13 +690,13 @@ void CRepeaterHandler::processRepeater(CHeaderData& header)
if (m_rptCall2 != (m_gwyCallsign) && m_rptCall2 != m_gateway) { if (m_rptCall2 != (m_gwyCallsign) && m_rptCall2 != m_gateway) {
CRepeaterHandler* repeater = findDVRepeater(m_rptCall2); CRepeaterHandler* repeater = findDVRepeater(m_rptCall2);
if (repeater != NULL) { if (repeater != NULL) {
wxLogMessage("Cross-band routing by %s from %s to %s", m_myCall1.c_str(), m_rptCallsign.c_str(), m_rptCall2.c_str()); CLog::logInfo("Cross-band routing by %s from %s to %s", m_myCall1.c_str(), m_rptCallsign.c_str(), m_rptCall2.c_str());
m_xBandRptr = repeater; m_xBandRptr = repeater;
m_xBandRptr->process(header, DIR_INCOMING, AS_XBAND); m_xBandRptr->process(header, DIR_INCOMING, AS_XBAND);
m_g2Status = G2_XBAND; m_g2Status = G2_XBAND;
} else { } else {
// Keep the transmission local // Keep the transmission local
wxLogMessage("Invalid cross-band route by %s from %s to %s", m_myCall1.c_str(), m_rptCallsign.c_str(), m_rptCall2.c_str()); CLog::logInfo("Invalid cross-band route by %s from %s to %s", m_myCall1.c_str(), m_rptCallsign.c_str(), m_rptCall2.c_str());
m_g2Status = G2_LOCAL; m_g2Status = G2_LOCAL;
} }
return; return;
@ -705,7 +705,7 @@ void CRepeaterHandler::processRepeater(CHeaderData& header)
#ifdef USE_STARNET #ifdef USE_STARNET
m_starNet = CStarNetHandler::findStarNet(header); m_starNet = CStarNetHandler::findStarNet(header);
if (m_starNet != NULL && !m_restricted) { if (m_starNet != NULL && !m_restricted) {
wxLogMessage(wxT("StarNet routing by %s to %s"), m_myCall1.c_str(), m_yourCall.c_str()); CLog::logInfo(wxT("StarNet routing by %s to %s"), m_myCall1.c_str(), m_yourCall.c_str());
m_starNet->process(header); m_starNet->process(header);
m_g2Status = G2_STARNET; m_g2Status = G2_STARNET;
return; return;
@ -992,12 +992,12 @@ void CRepeaterHandler::processBusy(CHeaderData& header)
m_band1 = band1; m_band1 = band1;
m_band2 = band2; m_band2 = band2;
m_band3 = band3; m_band3 = band3;
wxLogMessage("Repeater %s registered with bands %u %u %u", rptCall1.c_str(), m_band1, m_band2, m_band3); CLog::logInfo("Repeater %s registered with bands %u %u %u", rptCall1.c_str(), m_band1, m_band2, m_band3);
} }
} }
if (header.getFlag1() == 0x01) { if (header.getFlag1() == 0x01) {
wxLogMessage("Received a busy message from repeater %s", rptCall1.c_str()); CLog::logInfo("Received a busy message from repeater %s", rptCall1.c_str());
return; return;
} }
@ -1139,7 +1139,7 @@ void CRepeaterHandler::processRepeater(CDDData& data)
if (m_ddCallsign.empty()) { if (m_ddCallsign.empty()) {
m_ddCallsign = data.getYourCall(); m_ddCallsign = data.getYourCall();
wxLogMessage("Added DD callsign %s", m_ddCallsign.c_str()); CLog::logInfo("Added DD callsign %s", m_ddCallsign.c_str());
} }
CDDHandler::process(data); CDDHandler::process(data);
@ -1345,7 +1345,7 @@ void CRepeaterHandler::resolveRepeaterInt(const std::string& repeater, const std
CDPlusHandler::link(this, m_rptCallsign, m_linkRepeater, addr); CDPlusHandler::link(this, m_rptCallsign, m_linkRepeater, addr);
m_linkStatus = LS_LINKING_DPLUS; m_linkStatus = LS_LINKING_DPLUS;
} else { } else {
wxLogMessage("Require D-Plus for linking to %s, but D-Plus is disabled", repeater.c_str()); CLog::logInfo("Require D-Plus for linking to %s, but D-Plus is disabled", repeater.c_str());
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
m_linkRepeater.clear(); m_linkRepeater.clear();
m_linkGateway.clear(); m_linkGateway.clear();
@ -1361,7 +1361,7 @@ void CRepeaterHandler::resolveRepeaterInt(const std::string& repeater, const std
CDCSHandler::link(this, m_rptCallsign, m_linkRepeater, addr); CDCSHandler::link(this, m_rptCallsign, m_linkRepeater, addr);
m_linkStatus = LS_LINKING_DCS; m_linkStatus = LS_LINKING_DCS;
} else { } else {
wxLogMessage("Require DCS for linking to %s, but DCS is disabled", repeater.c_str()); CLog::logInfo("Require DCS for linking to %s, but DCS is disabled", repeater.c_str());
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
m_linkRepeater.clear(); m_linkRepeater.clear();
m_linkGateway.clear(); m_linkGateway.clear();
@ -1384,7 +1384,7 @@ void CRepeaterHandler::resolveRepeaterInt(const std::string& repeater, const std
CDExtraHandler::link(this, m_rptCallsign, m_linkRepeater, addr); CDExtraHandler::link(this, m_rptCallsign, m_linkRepeater, addr);
m_linkStatus = LS_LINKING_DEXTRA; m_linkStatus = LS_LINKING_DEXTRA;
} else { } else {
wxLogMessage("Require DExtra for linking to %s, but DExtra is disabled", repeater.c_str()); CLog::logInfo("Require DExtra for linking to %s, but DExtra is disabled", repeater.c_str());
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
m_linkRepeater.clear(); m_linkRepeater.clear();
m_linkGateway.clear(); m_linkGateway.clear();
@ -1426,7 +1426,7 @@ void CRepeaterHandler::clockInt(unsigned int ms)
if (m_linkReconnectTimer.isRunning() && m_linkReconnectTimer.hasExpired()) { if (m_linkReconnectTimer.isRunning() && m_linkReconnectTimer.hasExpired()) {
if (m_linkStatus != LS_NONE && (m_linkStartup.empty() || m_linkStartup == " ")) { if (m_linkStatus != LS_NONE && (m_linkStartup.empty() || m_linkStartup == " ")) {
// Unlink if linked to something // Unlink if linked to something
wxLogMessage("Reconnect timer has expired, unlinking %s from %s", m_rptCallsign.c_str(), m_linkRepeater.c_str()); CLog::logInfo("Reconnect timer has expired, unlinking %s from %s", m_rptCallsign.c_str(), m_linkRepeater.c_str());
CDExtraHandler::unlink(this); CDExtraHandler::unlink(this);
CDPlusHandler::unlink(this); CDPlusHandler::unlink(this);
@ -1441,7 +1441,7 @@ void CRepeaterHandler::clockInt(unsigned int ms)
} else if ((m_linkStatus == LS_NONE && !m_linkStartup.empty() && m_linkStartup != " ") || } else if ((m_linkStatus == LS_NONE && !m_linkStartup.empty() && m_linkStartup != " ") ||
(m_linkStatus != LS_NONE && m_linkRepeater != m_linkStartup)) { (m_linkStatus != LS_NONE && m_linkRepeater != m_linkStartup)) {
// Relink if not linked or linked to the wrong reflector // Relink if not linked or linked to the wrong reflector
wxLogMessage("Reconnect timer has expired, relinking %s to %s", m_rptCallsign.c_str(), m_linkStartup.c_str()); CLog::logInfo("Reconnect timer has expired, relinking %s to %s", m_rptCallsign.c_str(), m_linkStartup.c_str());
// Check for just a change of letter // Check for just a change of letter
if (m_linkStatus != LS_NONE) { if (m_linkStatus != LS_NONE) {
@ -1522,7 +1522,7 @@ void CRepeaterHandler::clockInt(unsigned int ms)
if (m_g2Status == G2_USER || m_g2Status == G2_REPEATER) { if (m_g2Status == G2_USER || m_g2Status == G2_REPEATER) {
// User or repeater not found in time, remove G2 settings // User or repeater not found in time, remove G2 settings
wxLogMessage("ircDDB did not reply within five seconds"); CLog::logInfo("ircDDB did not reply within five seconds");
m_g2Status = G2_LOCAL; m_g2Status = G2_LOCAL;
m_g2User.clear(); m_g2User.clear();
@ -1533,7 +1533,7 @@ void CRepeaterHandler::clockInt(unsigned int ms)
m_g2Header = NULL; m_g2Header = NULL;
} else if (m_linkStatus == LS_PENDING_IRCDDB) { } else if (m_linkStatus == LS_PENDING_IRCDDB) {
// Repeater not found in time // Repeater not found in time
wxLogMessage("ircDDB did not reply within five seconds"); CLog::logInfo("ircDDB did not reply within five seconds");
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
m_linkRepeater.clear(); m_linkRepeater.clear();
@ -1545,7 +1545,7 @@ void CRepeaterHandler::clockInt(unsigned int ms)
#ifdef USE_CCS #ifdef USE_CCS
else if (m_linkStatus == LS_LINKING_CCS) { else if (m_linkStatus == LS_LINKING_CCS) {
// CCS didn't reply in time // CCS didn't reply in time
wxLogMessage(wxT("CCS did not reply within five seconds")); CLog::logInfo(wxT("CCS did not reply within five seconds"));
m_ccsHandler->stopLink(); m_ccsHandler->stopLink();
@ -1565,7 +1565,7 @@ void CRepeaterHandler::clockInt(unsigned int ms)
// If the watchdog timer has expired, clean up // If the watchdog timer has expired, clean up
if (m_watchdogTimer.isRunning() && m_watchdogTimer.hasExpired()) { if (m_watchdogTimer.isRunning() && m_watchdogTimer.hasExpired()) {
wxLogMessage("Radio watchdog timer for %s has expired", m_rptCallsign.c_str()); CLog::logInfo("Radio watchdog timer for %s has expired", m_rptCallsign.c_str());
m_watchdogTimer.stop(); m_watchdogTimer.stop();
if (m_repeaterId != 0x00U) { if (m_repeaterId != 0x00U) {
@ -1657,28 +1657,28 @@ void CRepeaterHandler::clockInt(unsigned int ms)
void CRepeaterHandler::linkUp(DSTAR_PROTOCOL protocol, const std::string& callsign) void CRepeaterHandler::linkUp(DSTAR_PROTOCOL protocol, const std::string& callsign)
{ {
if (protocol == DP_DEXTRA && m_linkStatus == LS_LINKING_DEXTRA) { if (protocol == DP_DEXTRA && m_linkStatus == LS_LINKING_DEXTRA) {
wxLogMessage("DExtra link to %s established", callsign.c_str()); CLog::logInfo("DExtra link to %s established", callsign.c_str());
m_linkStatus = LS_LINKED_DEXTRA; m_linkStatus = LS_LINKED_DEXTRA;
writeLinkedTo(callsign); writeLinkedTo(callsign);
triggerInfo(); triggerInfo();
} }
if (protocol == DP_DPLUS && m_linkStatus == LS_LINKING_DPLUS) { if (protocol == DP_DPLUS && m_linkStatus == LS_LINKING_DPLUS) {
wxLogMessage("D-Plus link to %s established", callsign.c_str()); CLog::logInfo("D-Plus link to %s established", callsign.c_str());
m_linkStatus = LS_LINKED_DPLUS; m_linkStatus = LS_LINKED_DPLUS;
writeLinkedTo(callsign); writeLinkedTo(callsign);
triggerInfo(); triggerInfo();
} }
if (protocol == DP_DCS && m_linkStatus == LS_LINKING_DCS) { if (protocol == DP_DCS && m_linkStatus == LS_LINKING_DCS) {
wxLogMessage("DCS link to %s established", callsign.c_str()); CLog::logInfo("DCS link to %s established", callsign.c_str());
m_linkStatus = LS_LINKED_DCS; m_linkStatus = LS_LINKED_DCS;
writeLinkedTo(callsign); writeLinkedTo(callsign);
triggerInfo(); triggerInfo();
} }
if (protocol == DP_DCS && m_linkStatus == LS_LINKING_LOOPBACK) { if (protocol == DP_DCS && m_linkStatus == LS_LINKING_LOOPBACK) {
wxLogMessage("Loopback link to %s established", callsign.c_str()); CLog::logInfo("Loopback link to %s established", callsign.c_str());
m_linkStatus = LS_LINKED_LOOPBACK; m_linkStatus = LS_LINKED_LOOPBACK;
writeLinkedTo(callsign); writeLinkedTo(callsign);
triggerInfo(); triggerInfo();
@ -1690,7 +1690,7 @@ bool CRepeaterHandler::linkFailed(DSTAR_PROTOCOL protocol, const std::string& ca
// Is relink to another module required? // Is relink to another module required?
if (!isRecoverable && m_linkRelink) { if (!isRecoverable && m_linkRelink) {
m_linkRelink = false; m_linkRelink = false;
wxLogMessage("Relinking %s from %s to %s", m_rptCallsign.c_str(), callsign.c_str(), m_linkRepeater.c_str()); CLog::logInfo("Relinking %s from %s to %s", m_rptCallsign.c_str(), callsign.c_str(), m_linkRepeater.c_str());
linkInt(m_linkRepeater); linkInt(m_linkRepeater);
return false; return false;
} }
@ -1699,13 +1699,13 @@ bool CRepeaterHandler::linkFailed(DSTAR_PROTOCOL protocol, const std::string& ca
if (m_linkStatus == LS_NONE || m_linkRepeater != callsign) { if (m_linkStatus == LS_NONE || m_linkRepeater != callsign) {
switch (protocol) { switch (protocol) {
case DP_DCS: case DP_DCS:
wxLogMessage("DCS link to %s has failed", callsign.c_str()); CLog::logInfo("DCS link to %s has failed", callsign.c_str());
break; break;
case DP_DEXTRA: case DP_DEXTRA:
wxLogMessage("DExtra link to %s has failed", callsign.c_str()); CLog::logInfo("DExtra link to %s has failed", callsign.c_str());
break; break;
case DP_DPLUS: case DP_DPLUS:
wxLogMessage("D-Plus link to %s has failed", callsign.c_str()); CLog::logInfo("D-Plus link to %s has failed", callsign.c_str());
break; break;
default: default:
break; break;
@ -1716,7 +1716,7 @@ bool CRepeaterHandler::linkFailed(DSTAR_PROTOCOL protocol, const std::string& ca
if (!isRecoverable) { if (!isRecoverable) {
if (protocol == DP_DEXTRA && callsign == m_linkRepeater) { if (protocol == DP_DEXTRA && callsign == m_linkRepeater) {
wxLogMessage("DExtra link to %s has failed", m_linkRepeater.c_str()); CLog::logInfo("DExtra link to %s has failed", m_linkRepeater.c_str());
m_linkRepeater.clear(); m_linkRepeater.clear();
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeNotLinked(); writeNotLinked();
@ -1724,7 +1724,7 @@ bool CRepeaterHandler::linkFailed(DSTAR_PROTOCOL protocol, const std::string& ca
} }
if (protocol == DP_DPLUS && callsign == m_linkRepeater) { if (protocol == DP_DPLUS && callsign == m_linkRepeater) {
wxLogMessage("D-Plus link to %s has failed", m_linkRepeater.c_str()); CLog::logInfo("D-Plus link to %s has failed", m_linkRepeater.c_str());
m_linkRepeater.clear(); m_linkRepeater.clear();
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeNotLinked(); writeNotLinked();
@ -1733,9 +1733,9 @@ bool CRepeaterHandler::linkFailed(DSTAR_PROTOCOL protocol, const std::string& ca
if (protocol == DP_DCS && callsign == m_linkRepeater) { if (protocol == DP_DCS && callsign == m_linkRepeater) {
if (m_linkStatus == LS_LINKED_DCS || m_linkStatus == LS_LINKING_DCS) if (m_linkStatus == LS_LINKED_DCS || m_linkStatus == LS_LINKING_DCS)
wxLogMessage("DCS link to %s has failed", m_linkRepeater.c_str()); CLog::logInfo("DCS link to %s has failed", m_linkRepeater.c_str());
else else
wxLogMessage("Loopback link to %s has failed", m_linkRepeater.c_str()); CLog::logInfo("Loopback link to %s has failed", m_linkRepeater.c_str());
m_linkRepeater.clear(); m_linkRepeater.clear();
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeNotLinked(); writeNotLinked();
@ -1748,7 +1748,7 @@ bool CRepeaterHandler::linkFailed(DSTAR_PROTOCOL protocol, const std::string& ca
if (protocol == DP_DEXTRA) { if (protocol == DP_DEXTRA) {
switch (m_linkStatus) { switch (m_linkStatus) {
case LS_LINKED_DEXTRA: case LS_LINKED_DEXTRA:
wxLogMessage("DExtra link to %s has failed, relinking", m_linkRepeater.c_str()); CLog::logInfo("DExtra link to %s has failed, relinking", m_linkRepeater.c_str());
m_linkStatus = LS_LINKING_DEXTRA; m_linkStatus = LS_LINKING_DEXTRA;
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
@ -1765,7 +1765,7 @@ bool CRepeaterHandler::linkFailed(DSTAR_PROTOCOL protocol, const std::string& ca
if (protocol == DP_DPLUS) { if (protocol == DP_DPLUS) {
switch (m_linkStatus) { switch (m_linkStatus) {
case LS_LINKED_DPLUS: case LS_LINKED_DPLUS:
wxLogMessage("D-Plus link to %s has failed, relinking", m_linkRepeater.c_str()); CLog::logInfo("D-Plus link to %s has failed, relinking", m_linkRepeater.c_str());
m_linkStatus = LS_LINKING_DPLUS; m_linkStatus = LS_LINKING_DPLUS;
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
@ -1782,14 +1782,14 @@ bool CRepeaterHandler::linkFailed(DSTAR_PROTOCOL protocol, const std::string& ca
if (protocol == DP_DCS) { if (protocol == DP_DCS) {
switch (m_linkStatus) { switch (m_linkStatus) {
case LS_LINKED_DCS: case LS_LINKED_DCS:
wxLogMessage("DCS link to %s has failed, relinking", m_linkRepeater.c_str()); CLog::logInfo("DCS link to %s has failed, relinking", m_linkRepeater.c_str());
m_linkStatus = LS_LINKING_DCS; m_linkStatus = LS_LINKING_DCS;
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
return true; return true;
case LS_LINKED_LOOPBACK: case LS_LINKED_LOOPBACK:
wxLogMessage("Loopback link to %s has failed, relinking", m_linkRepeater.c_str()); CLog::logInfo("Loopback link to %s has failed, relinking", m_linkRepeater.c_str());
m_linkStatus = LS_LINKING_LOOPBACK; m_linkStatus = LS_LINKING_LOOPBACK;
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
@ -1810,7 +1810,7 @@ bool CRepeaterHandler::linkFailed(DSTAR_PROTOCOL protocol, const std::string& ca
void CRepeaterHandler::linkRefused(DSTAR_PROTOCOL protocol, const std::string& callsign) void CRepeaterHandler::linkRefused(DSTAR_PROTOCOL protocol, const std::string& callsign)
{ {
if (protocol == DP_DEXTRA && callsign == m_linkRepeater) { if (protocol == DP_DEXTRA && callsign == m_linkRepeater) {
wxLogMessage("DExtra link to %s was refused", m_linkRepeater.c_str()); CLog::logInfo("DExtra link to %s was refused", m_linkRepeater.c_str());
m_linkRepeater.clear(); m_linkRepeater.clear();
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeIsBusy(callsign); writeIsBusy(callsign);
@ -1818,7 +1818,7 @@ void CRepeaterHandler::linkRefused(DSTAR_PROTOCOL protocol, const std::string& c
} }
if (protocol == DP_DPLUS && callsign == m_linkRepeater) { if (protocol == DP_DPLUS && callsign == m_linkRepeater) {
wxLogMessage("D-Plus link to %s was refused", m_linkRepeater.c_str()); CLog::logInfo("D-Plus link to %s was refused", m_linkRepeater.c_str());
m_linkRepeater.clear(); m_linkRepeater.clear();
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeIsBusy(callsign); writeIsBusy(callsign);
@ -1827,9 +1827,9 @@ void CRepeaterHandler::linkRefused(DSTAR_PROTOCOL protocol, const std::string& c
if (protocol == DP_DCS && callsign == m_linkRepeater) { if (protocol == DP_DCS && callsign == m_linkRepeater) {
if (m_linkStatus == LS_LINKED_DCS || m_linkStatus == LS_LINKING_DCS) if (m_linkStatus == LS_LINKED_DCS || m_linkStatus == LS_LINKING_DCS)
wxLogMessage("DCS link to %s was refused", m_linkRepeater.c_str()); CLog::logInfo("DCS link to %s was refused", m_linkRepeater.c_str());
else else
wxLogMessage("Loopback link to %s was refused", m_linkRepeater.c_str()); CLog::logInfo("Loopback link to %s was refused", m_linkRepeater.c_str());
m_linkRepeater.clear(); m_linkRepeater.clear();
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeIsBusy(callsign); writeIsBusy(callsign);
@ -1842,7 +1842,7 @@ void CRepeaterHandler::link(RECONNECT reconnect, const std::string& reflector)
#ifdef USE_CCS #ifdef USE_CCS
// CCS removal // CCS removal
if (m_linkStatus == LS_LINKING_CCS || m_linkStatus == LS_LINKED_CCS) { if (m_linkStatus == LS_LINKING_CCS || m_linkStatus == LS_LINKED_CCS) {
wxLogMessage(wxT("Dropping CCS link to %s"), m_linkRepeater.c_str()); CLog::logInfo(wxT("Dropping CCS link to %s"), m_linkRepeater.c_str());
m_ccsHandler->stopLink(); m_ccsHandler->stopLink();
@ -1899,7 +1899,7 @@ void CRepeaterHandler::link(RECONNECT reconnect, const std::string& reflector)
// Handle unlinking // Handle unlinking
if (m_linkStatus != LS_NONE && (reflector.empty() || reflector == " ")) { if (m_linkStatus != LS_NONE && (reflector.empty() || reflector == " ")) {
wxLogMessage("Unlinking %s from %s", m_rptCallsign.c_str(), m_linkRepeater.c_str()); CLog::logInfo("Unlinking %s from %s", m_rptCallsign.c_str(), m_linkRepeater.c_str());
CDExtraHandler::unlink(this); CDExtraHandler::unlink(this);
CDPlusHandler::unlink(this); CDPlusHandler::unlink(this);
@ -1914,7 +1914,7 @@ void CRepeaterHandler::link(RECONNECT reconnect, const std::string& reflector)
return; return;
} }
wxLogMessage("Linking %s to %s", m_rptCallsign.c_str(), reflector.c_str()); CLog::logInfo("Linking %s to %s", m_rptCallsign.c_str(), reflector.c_str());
// Check for just a change of letter // Check for just a change of letter
if (m_linkStatus != LS_NONE) { if (m_linkStatus != LS_NONE) {
@ -1996,7 +1996,7 @@ void CRepeaterHandler::unlink(PROTOCOL protocol, const std::string& reflector)
#endif #endif
if (m_linkReconnect == RECONNECT_FIXED && m_linkRepeater == (reflector)) { if (m_linkReconnect == RECONNECT_FIXED && m_linkRepeater == (reflector)) {
wxLogMessage("Cannot unlink %s because it is fixed", reflector.c_str()); CLog::logInfo("Cannot unlink %s because it is fixed", reflector.c_str());
return; return;
} }
@ -2025,7 +2025,7 @@ void CRepeaterHandler::g2CommandHandler(const std::string& callsign, const std::
if (callsign.substr(0,1) == "/") { if (callsign.substr(0,1) == "/") {
if (m_irc == NULL) { if (m_irc == NULL) {
wxLogMessage("%s is trying to G2 route with ircDDB disabled", user.c_str()); CLog::logInfo("%s is trying to G2 route with ircDDB disabled", user.c_str());
m_g2Status = G2_LOCAL; m_g2Status = G2_LOCAL;
return; return;
} }
@ -2037,18 +2037,18 @@ void CRepeaterHandler::g2CommandHandler(const std::string& callsign, const std::
repeater += callsign.substr(callsign.length() - 1, 1); repeater += callsign.substr(callsign.length() - 1, 1);
if (repeater == m_rptCallsign) { if (repeater == m_rptCallsign) {
wxLogMessage("%s is trying to G2 route to self, ignoring", user.c_str()); CLog::logInfo("%s is trying to G2 route to self, ignoring", user.c_str());
m_g2Status = G2_LOCAL; m_g2Status = G2_LOCAL;
return; return;
} }
if (repeater.substr(0,3U) == "REF" || repeater.substr(0,3U) == "XRF" || repeater.substr(0,3U) == "DCS") { if (repeater.substr(0,3U) == "REF" || repeater.substr(0,3U) == "XRF" || repeater.substr(0,3U) == "DCS") {
wxLogMessage("%s is trying to G2 route to reflector %s, ignoring", user.c_str(), repeater.c_str()); CLog::logInfo("%s is trying to G2 route to reflector %s, ignoring", user.c_str(), repeater.c_str());
m_g2Status = G2_LOCAL; m_g2Status = G2_LOCAL;
return; return;
} }
wxLogMessage("%s is trying to G2 route to repeater %s", user.c_str(), repeater.c_str()); CLog::logInfo("%s is trying to G2 route to repeater %s", user.c_str(), repeater.c_str());
m_g2Repeater = repeater; m_g2Repeater = repeater;
m_g2User = wxT("CQCQCQ "); m_g2User = wxT("CQCQCQ ");
@ -2071,19 +2071,19 @@ void CRepeaterHandler::g2CommandHandler(const std::string& callsign, const std::
} }
} else if (string_right(callsign, 1) != "L" && string_right(callsign, 1) == "U") { } else if (string_right(callsign, 1) != "L" && string_right(callsign, 1) == "U") {
if (m_irc == NULL) { if (m_irc == NULL) {
wxLogMessage("%s is trying to G2 route with ircDDB disabled", user.c_str()); CLog::logInfo("%s is trying to G2 route with ircDDB disabled", user.c_str());
m_g2Status = G2_LOCAL; m_g2Status = G2_LOCAL;
return; return;
} }
// This a callsign route // This a callsign route
if (callsign.substr(0,3U) == "REF" || callsign.substr(0,3U) == "XRF" || callsign.substr(0,3U) == "DCS") { if (callsign.substr(0,3U) == "REF" || callsign.substr(0,3U) == "XRF" || callsign.substr(0,3U) == "DCS") {
wxLogMessage("%s is trying to G2 route to reflector %s, ignoring", user.c_str(), callsign.c_str()); CLog::logInfo("%s is trying to G2 route to reflector %s, ignoring", user.c_str(), callsign.c_str());
m_g2Status = G2_LOCAL; m_g2Status = G2_LOCAL;
return; return;
} }
wxLogMessage("%s is trying to G2 route to callsign %s", user.c_str(), callsign.c_str()); CLog::logInfo("%s is trying to G2 route to callsign %s", user.c_str(), callsign.c_str());
CUserData* data = m_cache->findUser(callsign); CUserData* data = m_cache->findUser(callsign);
@ -2150,7 +2150,7 @@ void CRepeaterHandler::reflectorCommandHandler(const std::string& callsign, cons
if (m_linkStatus == LS_NONE) if (m_linkStatus == LS_NONE)
return; return;
wxLogMessage("Unlink command issued via %s by %s", type.c_str(), user.c_str()); CLog::logInfo("Unlink command issued via %s by %s", type.c_str(), user.c_str());
CDExtraHandler::unlink(this); CDExtraHandler::unlink(this);
CDPlusHandler::unlink(this); CDPlusHandler::unlink(this);
@ -2183,12 +2183,12 @@ void CRepeaterHandler::reflectorCommandHandler(const std::string& callsign, cons
// We can't link to ourself // We can't link to ourself
if (reflector == m_rptCallsign) { if (reflector == m_rptCallsign) {
wxLogMessage("%s is trying to link with self via %s, ignoring", user.c_str(), type.c_str()); CLog::logInfo("%s is trying to link with self via %s, ignoring", user.c_str(), type.c_str());
triggerInfo(); triggerInfo();
return; return;
} }
wxLogMessage("Link command from %s to %s issued via %s by %s", m_rptCallsign.c_str(), reflector.c_str(), type.c_str(), user.c_str()); CLog::logInfo("Link command from %s to %s issued via %s by %s", m_rptCallsign.c_str(), reflector.c_str(), type.c_str(), user.c_str());
// Check for just a change of letter // Check for just a change of letter
if (m_linkStatus != LS_NONE) { if (m_linkStatus != LS_NONE) {
@ -2268,7 +2268,7 @@ void CRepeaterHandler::linkInt(const std::string& callsign)
// Are we trying to link to an unknown DExtra, D-Plus, or DCS reflector? // Are we trying to link to an unknown DExtra, D-Plus, or DCS reflector?
if (data == NULL && (callsign.substr(0,3U) == "REF" || callsign.substr(0,3U) == "XRF" || callsign.substr(0,3U) == "DCS")) { if (data == NULL && (callsign.substr(0,3U) == "REF" || callsign.substr(0,3U) == "XRF" || callsign.substr(0,3U) == "DCS")) {
wxLogMessage("%s is unknown, ignoring link request", callsign.c_str()); CLog::logInfo("%s is unknown, ignoring link request", callsign.c_str());
triggerInfo(); triggerInfo();
return; return;
} }
@ -2286,7 +2286,7 @@ void CRepeaterHandler::linkInt(const std::string& callsign)
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
} else { } else {
wxLogMessage("Require D-Plus for linking to %s, but D-Plus is disabled", callsign.c_str()); CLog::logInfo("Require D-Plus for linking to %s, but D-Plus is disabled", callsign.c_str());
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeNotLinked(); writeNotLinked();
triggerInfo(); triggerInfo();
@ -2300,7 +2300,7 @@ void CRepeaterHandler::linkInt(const std::string& callsign)
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
} else { } else {
wxLogMessage("Require DCS for linking to %s, but DCS is disabled", callsign.c_str()); CLog::logInfo("Require DCS for linking to %s, but DCS is disabled", callsign.c_str());
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeNotLinked(); writeNotLinked();
triggerInfo(); triggerInfo();
@ -2321,7 +2321,7 @@ void CRepeaterHandler::linkInt(const std::string& callsign)
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
} else { } else {
wxLogMessage("Require DExtra for linking to %s, but DExtra is disabled", callsign.c_str()); CLog::logInfo("Require DExtra for linking to %s, but DExtra is disabled", callsign.c_str());
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeNotLinked(); writeNotLinked();
triggerInfo(); triggerInfo();
@ -2435,7 +2435,7 @@ void CRepeaterHandler::startupInt()
// Link to a startup reflector/repeater // Link to a startup reflector/repeater
if (m_linkAtStartup && !m_linkStartup.empty()) { if (m_linkAtStartup && !m_linkStartup.empty()) {
wxLogMessage("Linking %s at startup to %s", m_rptCallsign.c_str(), m_linkStartup.c_str()); CLog::logInfo("Linking %s at startup to %s", m_rptCallsign.c_str(), m_linkStartup.c_str());
// Find the repeater to link to // Find the repeater to link to
CRepeaterData* data = m_cache->findRepeater(m_linkStartup); CRepeaterData* data = m_cache->findRepeater(m_linkStartup);
@ -2454,7 +2454,7 @@ void CRepeaterHandler::startupInt()
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
} else { } else {
wxLogMessage("Require D-Plus for linking to %s, but D-Plus is disabled", m_linkRepeater.c_str()); CLog::logInfo("Require D-Plus for linking to %s, but D-Plus is disabled", m_linkRepeater.c_str());
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeNotLinked(); writeNotLinked();
triggerInfo(); triggerInfo();
@ -2468,7 +2468,7 @@ void CRepeaterHandler::startupInt()
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
} else { } else {
wxLogMessage("Require DCS for linking to %s, but DCS is disabled", m_linkRepeater.c_str()); CLog::logInfo("Require DCS for linking to %s, but DCS is disabled", m_linkRepeater.c_str());
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeNotLinked(); writeNotLinked();
triggerInfo(); triggerInfo();
@ -2489,7 +2489,7 @@ void CRepeaterHandler::startupInt()
writeLinkingTo(m_linkRepeater); writeLinkingTo(m_linkRepeater);
triggerInfo(); triggerInfo();
} else { } else {
wxLogMessage("Require DExtra for linking to %s, but DExtra is disabled", m_linkRepeater.c_str()); CLog::logInfo("Require DExtra for linking to %s, but DExtra is disabled", m_linkRepeater.c_str());
m_linkStatus = LS_NONE; m_linkStatus = LS_NONE;
writeNotLinked(); writeNotLinked();
triggerInfo(); triggerInfo();

@ -37,7 +37,7 @@ IRepeaterProtocolHandler * CRepeaterHandlerFactory::getRepeaterProtocolHandler(H
CIcomRepeaterProtocolHandler * icomRepeaterHandler = new CIcomRepeaterProtocolHandler(gatewayConfig.icomAddress, gatewayConfig.icomPort, repeaterAddress, repeaterPort); CIcomRepeaterProtocolHandler * icomRepeaterHandler = new CIcomRepeaterProtocolHandler(gatewayConfig.icomAddress, gatewayConfig.icomPort, repeaterAddress, repeaterPort);
bool res = icomRepeaterHandler->open(); bool res = icomRepeaterHandler->open();
if (!res) { if (!res) {
wxLogError("Cannot open the Icom repeater protocol handler"); CLog::logError("Cannot open the Icom repeater protocol handler");
delete icomRepeaterHandler; delete icomRepeaterHandler;
icomRepeaterHandler = NULL; icomRepeaterHandler = NULL;
} }
@ -50,7 +50,7 @@ IRepeaterProtocolHandler * CRepeaterHandlerFactory::getRepeaterProtocolHandler(H
CHBRepeaterProtocolHandler * hbRepeaterHandler = new CHBRepeaterProtocolHandler(gatewayConfig.hbAddress, gatewayConfig.hbPort); CHBRepeaterProtocolHandler * hbRepeaterHandler = new CHBRepeaterProtocolHandler(gatewayConfig.hbAddress, gatewayConfig.hbPort);
bool res = hbRepeaterHandler->open(); bool res = hbRepeaterHandler->open();
if (!res) { if (!res) {
wxLogError("Cannot open the Homebrew repeater protocol handler"); CLog::logError("Cannot open the Homebrew repeater protocol handler");
delete hbRepeaterHandler; delete hbRepeaterHandler;
hbRepeaterHandler = NULL; hbRepeaterHandler = NULL;
} }
@ -63,7 +63,7 @@ IRepeaterProtocolHandler * CRepeaterHandlerFactory::getRepeaterProtocolHandler(H
CDummyRepeaterProtocolHandler * dummyRepeaterHandler = new CDummyRepeaterProtocolHandler; CDummyRepeaterProtocolHandler * dummyRepeaterHandler = new CDummyRepeaterProtocolHandler;
bool res = dummyRepeaterHandler->open(); bool res = dummyRepeaterHandler->open();
if (!res) { if (!res) {
wxLogError("Cannot open the Dummy repeater protocol handler"); CLog::logError("Cannot open the Dummy repeater protocol handler");
delete dummyRepeaterHandler; delete dummyRepeaterHandler;
dummyRepeaterHandler = NULL; dummyRepeaterHandler = NULL;
} }

@ -25,7 +25,7 @@
#include "TCPReaderWriterClient.h" #include "TCPReaderWriterClient.h"
#include "UDPReaderWriter.h" #include "UDPReaderWriter.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
CTCPReaderWriterClient::CTCPReaderWriterClient(const std::string& address, unsigned int port, const std::string& localAddress) : CTCPReaderWriterClient::CTCPReaderWriterClient(const std::string& address, unsigned int port, const std::string& localAddress) :
m_address(address), m_address(address),
@ -77,7 +77,7 @@ bool CTCPReaderWriterClient::open()
m_fd = ::socket(PF_INET, SOCK_STREAM, 0); m_fd = ::socket(PF_INET, SOCK_STREAM, 0);
if (m_fd < 0) { if (m_fd < 0) {
printf("Cannot create the TCP client socket, err=%d\n", errno); CLog::logInfo("Cannot create the TCP client socket, err=%d\n", errno);
return false; return false;
} }
@ -88,13 +88,13 @@ bool CTCPReaderWriterClient::open()
addr.sin_port = 0U; addr.sin_port = 0U;
addr.sin_addr.s_addr = ::inet_addr(m_localAddress.c_str()); addr.sin_addr.s_addr = ::inet_addr(m_localAddress.c_str());
if (addr.sin_addr.s_addr == INADDR_NONE) { if (addr.sin_addr.s_addr == INADDR_NONE) {
printf("The address is invalid - %s\n", m_localAddress.c_str()); CLog::logInfo("The address is invalid - %s\n", m_localAddress.c_str());
close(); close();
return false; return false;
} }
if (::bind(m_fd, (sockaddr*)&addr, sizeof(sockaddr_in)) == -1) { if (::bind(m_fd, (sockaddr*)&addr, sizeof(sockaddr_in)) == -1) {
printf("Cannot bind the TCP client address, err=%d\n", errno); CLog::logInfo("Cannot bind the TCP client address, err=%d\n", errno);
close(); close();
return false; return false;
} }
@ -112,14 +112,14 @@ bool CTCPReaderWriterClient::open()
} }
if (::connect(m_fd, (sockaddr*)&addr, sizeof(struct sockaddr_in)) == -1) { if (::connect(m_fd, (sockaddr*)&addr, sizeof(struct sockaddr_in)) == -1) {
printf("Cannot connect the TCP client socket, err=%d\n", errno); CLog::logInfo("Cannot connect the TCP client socket, err=%d\n", errno);
close(); close();
return false; return false;
} }
int noDelay = 1; int noDelay = 1;
if (::setsockopt(m_fd, IPPROTO_TCP, TCP_NODELAY, (char *)&noDelay, sizeof(noDelay)) == -1) { if (::setsockopt(m_fd, IPPROTO_TCP, TCP_NODELAY, (char *)&noDelay, sizeof(noDelay)) == -1) {
printf("Cannot set the TCP client socket option, err=%d\n", errno); CLog::logInfo("Cannot set the TCP client socket option, err=%d\n", errno);
close(); close();
return false; return false;
} }
@ -145,7 +145,7 @@ int CTCPReaderWriterClient::read(unsigned char* buffer, unsigned int length, uns
int ret = ::select(m_fd + 1, &readFds, NULL, NULL, &tv); int ret = ::select(m_fd + 1, &readFds, NULL, NULL, &tv);
if (ret < 0) { if (ret < 0) {
printf("Error returned from TCP client select, err=%d\n", errno); CLog::logInfo("Error returned from TCP client select, err=%d\n", errno);
return -1; return -1;
} }
@ -156,7 +156,7 @@ int CTCPReaderWriterClient::read(unsigned char* buffer, unsigned int length, uns
if (len == 0) { if (len == 0) {
return -2; return -2;
} else if (len < 0) { } else if (len < 0) {
printf("Error returned from recv, err=%d\n", errno); CLog::logInfo("Error returned from recv, err=%d\n", errno);
return -1; return -1;
} }
@ -192,7 +192,7 @@ bool CTCPReaderWriterClient::write(const unsigned char* buffer, unsigned int len
ssize_t ret = ::send(m_fd, (char *)buffer, length, 0); ssize_t ret = ::send(m_fd, (char *)buffer, length, 0);
if (ret != ssize_t(length)) { if (ret != ssize_t(length)) {
printf("Error returned from send, err=%d\n", errno); CLog::logInfo("Error returned from send, err=%d\n", errno);
return false; return false;
} }

@ -20,6 +20,7 @@
#include <cstring> #include <cstring>
#include <string.h> #include <string.h>
#include "UDPReaderWriter.h" #include "UDPReaderWriter.h"
#include "Log.h"
CUDPReaderWriter::CUDPReaderWriter(const std::string& address, unsigned int port) : CUDPReaderWriter::CUDPReaderWriter(const std::string& address, unsigned int port) :
m_address(address), m_address(address),
@ -56,7 +57,7 @@ in_addr CUDPReaderWriter::lookup(const std::string& hostname)
return addr; return addr;
} }
printf("Cannot find address for host %s\n", hostname.c_str()); CLog::logInfo("Cannot find address for host %s\n", hostname.c_str());
addr.s_addr = INADDR_NONE; addr.s_addr = INADDR_NONE;
return addr; return addr;
@ -66,7 +67,7 @@ bool CUDPReaderWriter::open()
{ {
m_fd = ::socket(PF_INET, SOCK_DGRAM, 0); m_fd = ::socket(PF_INET, SOCK_DGRAM, 0);
if (m_fd < 0) { if (m_fd < 0) {
printf("Cannot create the UDP socket, err: %s\n", strerror(errno)); CLog::logInfo("Cannot create the UDP socket, err: %s\n", strerror(errno));
return false; return false;
} }
@ -80,19 +81,19 @@ bool CUDPReaderWriter::open()
if (m_address.size()) { if (m_address.size()) {
addr.sin_addr.s_addr = ::inet_addr(m_address.c_str()); addr.sin_addr.s_addr = ::inet_addr(m_address.c_str());
if (addr.sin_addr.s_addr == INADDR_NONE) { if (addr.sin_addr.s_addr == INADDR_NONE) {
printf("The address is invalid - %s\n", m_address.c_str()); CLog::logInfo("The address is invalid - %s\n", m_address.c_str());
return false; return false;
} }
} }
int reuse = 1; int reuse = 1;
if (::setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) == -1) { if (::setsockopt(m_fd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) == -1) {
printf("Cannot set the UDP socket option (port: %u), err: %s\n", m_port, strerror(errno)); CLog::logInfo("Cannot set the UDP socket option (port: %u), err: %s\n", m_port, strerror(errno));
return false; return false;
} }
if (::bind(m_fd, (sockaddr*)&addr, sizeof(sockaddr_in)) == -1) { if (::bind(m_fd, (sockaddr*)&addr, sizeof(sockaddr_in)) == -1) {
printf("Cannot bind the UDP address (port: %u), err: %s\n", m_port, strerror(errno)); CLog::logInfo("Cannot bind the UDP address (port: %u), err: %s\n", m_port, strerror(errno));
return false; return false;
} }
} }
@ -114,7 +115,7 @@ int CUDPReaderWriter::read(unsigned char* buffer, unsigned int length, in_addr&
int ret = ::select(m_fd + 1, &readFds, NULL, NULL, &tv); int ret = ::select(m_fd + 1, &readFds, NULL, NULL, &tv);
if (ret < 0) { if (ret < 0) {
printf("Error returned from UDP select (port: %u), err: %s\n", m_port, strerror(errno)); CLog::logInfo("Error returned from UDP select (port: %u), err: %s\n", m_port, strerror(errno));
return -1; return -1;
} }
@ -126,7 +127,7 @@ int CUDPReaderWriter::read(unsigned char* buffer, unsigned int length, in_addr&
ssize_t len = ::recvfrom(m_fd, (char*)buffer, length, 0, (sockaddr *)&addr, &size); ssize_t len = ::recvfrom(m_fd, (char*)buffer, length, 0, (sockaddr *)&addr, &size);
if (len <= 0) { if (len <= 0) {
printf("Error returned from recvfrom (port: %u), err: %s\n", m_port, strerror(errno)); CLog::logInfo("Error returned from recvfrom (port: %u), err: %s\n", m_port, strerror(errno));
return -1; return -1;
} }
@ -147,7 +148,7 @@ bool CUDPReaderWriter::write(const unsigned char* buffer, unsigned int length, c
ssize_t ret = ::sendto(m_fd, (char *)buffer, length, 0, (sockaddr *)&addr, sizeof(sockaddr_in)); ssize_t ret = ::sendto(m_fd, (char *)buffer, length, 0, (sockaddr *)&addr, sizeof(sockaddr_in));
if (ret < 0) { if (ret < 0) {
printf("Error returned from sendto (port: %u), err: %s\n", m_port, strerror(errno)); CLog::logInfo("Error returned from sendto (port: %u), err: %s\n", m_port, strerror(errno));
return false; return false;
} }

@ -29,13 +29,14 @@
#include <fstream> #include <fstream>
#include "Utils.h" #include "Utils.h"
#include "Log.h"
void CUtils::dump(const char* title, const bool* data, unsigned int length) void CUtils::dump(const char* title, const bool* data, unsigned int length)
{ {
assert(title != NULL); assert(title != NULL);
assert(data != NULL); assert(data != NULL);
printf("%s\n", title); CLog::logInfo("%s\n", title);
unsigned int offset = 0U; unsigned int offset = 0U;
@ -69,7 +70,7 @@ void CUtils::dump(const char* title, const bool* data, unsigned int length)
output += "*'"; output += "*'";
printf("%04X: %s\n", offset / 8U, output.c_str()); CLog::logInfo("%04X: %s\n", offset / 8U, output.c_str());
offset += 128U; offset += 128U;
} }
@ -80,7 +81,7 @@ void CUtils::dumpRev(const char* title, const bool* data, unsigned int length)
assert(title != NULL); assert(title != NULL);
assert(data != NULL); assert(data != NULL);
printf("%s\n", title); CLog::logInfo("%s\n", title);
unsigned int offset = 0U; unsigned int offset = 0U;
@ -114,7 +115,7 @@ void CUtils::dumpRev(const char* title, const bool* data, unsigned int length)
output += "*"; output += "*";
printf("%04X: %s\n", offset / 8U, output.c_str()); CLog::logInfo("%04X: %s\n", offset / 8U, output.c_str());
offset += 128U; offset += 128U;
} }
@ -125,7 +126,7 @@ void CUtils::dump(const char* title, const unsigned char* data, unsigned int len
assert(title != NULL); assert(title != NULL);
assert(data != NULL); assert(data != NULL);
printf("%s\n", title); CLog::logInfo("%s\n", title);
unsigned int offset = 0U; unsigned int offset = 0U;
@ -156,7 +157,7 @@ void CUtils::dump(const char* title, const unsigned char* data, unsigned int len
output += "*"; output += "*";
printf("%04X: %s\n", offset, output.c_str()); CLog::logInfo("%04X: %s\n", offset, output.c_str());
offset += 16U; offset += 16U;
@ -374,7 +375,7 @@ int CUtils::getAllIPV4Addresses(const char *name, unsigned short port, unsigned
return 0; return 0;
} else { } else {
std::string e(gai_strerror(r)); std::string e(gai_strerror(r));
printf("getaddrinfo: %s\n", e.c_str()); CLog::logInfo("getaddrinfo: %s\n", e.c_str());
return 1; return 1;
} }
} }

@ -28,6 +28,7 @@
#include "HeaderData.h" #include "HeaderData.h"
#include "Version.h" #include "Version.h"
#include "Utils.h" #include "Utils.h"
#include "Log.h"
const unsigned int NUM_FRAMES = 20U; const unsigned int NUM_FRAMES = 20U;
@ -47,7 +48,7 @@ m_out(0U)
char vstr[32]; char vstr[32];
snprintf(vstr, 32, "ircDDB GW - %s", VERSION.substr(0, 8).c_str()); snprintf(vstr, 32, "ircDDB GW - %s", VERSION.substr(0, 8).c_str());
printf("Version text set to \"%s\"\n", vstr); CLog::logInfo("Version text set to \"%s\"\n", vstr);
CSlowDataEncoder encoder; CSlowDataEncoder encoder;
encoder.setTextData(std::string(vstr)); encoder.setTextData(std::string(vstr));

Loading…
Cancel
Save

Powered by TurnKey Linux.