add debug logging switch

pull/9/head
Christoph Kottke 7 years ago
parent ace248cb40
commit d23b2a374c

@ -63,6 +63,7 @@ wxEND_EVENT_TABLE()
const wxString NAME_PARAM = "Repeater Name"; const wxString NAME_PARAM = "Repeater Name";
const wxString NOLOGGING_SWITCH = "nolog"; const wxString NOLOGGING_SWITCH = "nolog";
const wxString DEBUG_SWITCH = "debug";
const wxString GUI_SWITCH = "gui"; const wxString GUI_SWITCH = "gui";
const wxString LOGDIR_OPTION = "logdir"; const wxString LOGDIR_OPTION = "logdir";
const wxString CONFDIR_OPTION = "confdir"; const wxString CONFDIR_OPTION = "confdir";
@ -80,6 +81,7 @@ m_frame(NULL),
#endif #endif
m_name(), m_name(),
m_nolog(false), m_nolog(false),
m_debug(false),
m_gui(false), m_gui(false),
m_logDir(), m_logDir(),
m_confDir(), m_confDir(),
@ -120,6 +122,14 @@ bool CDStarRepeaterApp::OnInit()
try { try {
CLogger* log = new CLogger(m_logDir, logBaseName); CLogger* log = new CLogger(m_logDir, logBaseName);
wxLog::SetActiveTarget(log); wxLog::SetActiveTarget(log);
if (m_debug) {
wxLog::SetVerbose(true);
wxLog::SetLogLevel(wxLOG_Debug);
} else {
wxLog::SetVerbose(false);
wxLog::SetLogLevel(wxLOG_Message);
}
} catch ( const std::runtime_error& e ) { } catch ( const std::runtime_error& e ) {
wxLog::SetActiveTarget(new wxLogStderr()); wxLog::SetActiveTarget(new wxLogStderr());
wxLogError("Could not open log file, logging to stderr"); wxLogError("Could not open log file, logging to stderr");
@ -218,6 +228,7 @@ int CDStarRepeaterApp::OnExit()
void CDStarRepeaterApp::OnInitCmdLine(wxCmdLineParser& parser) void CDStarRepeaterApp::OnInitCmdLine(wxCmdLineParser& parser)
{ {
parser.AddSwitch(NOLOGGING_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL); parser.AddSwitch(NOLOGGING_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddSwitch(DEBUG_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddSwitch(GUI_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL); parser.AddSwitch(GUI_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddOption(LOGDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); parser.AddOption(LOGDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddOption(CONFDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL); parser.AddOption(CONFDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
@ -233,6 +244,7 @@ bool CDStarRepeaterApp::OnCmdLineParsed(wxCmdLineParser& parser)
return false; return false;
m_nolog = parser.Found(NOLOGGING_SWITCH); m_nolog = parser.Found(NOLOGGING_SWITCH);
m_debug = parser.Found(DEBUG_SWITCH);
m_gui = parser.Found(GUI_SWITCH); m_gui = parser.Found(GUI_SWITCH);
wxString logDir; wxString logDir;

@ -68,6 +68,7 @@ private:
wxString m_name; wxString m_name;
bool m_nolog; bool m_nolog;
bool m_debug;
bool m_gui; bool m_gui;
wxString m_logDir; wxString m_logDir;
wxString m_confDir; wxString m_confDir;

@ -101,6 +101,8 @@ void *CDStarRepeaterRXThread::Entry()
} else { } else {
clock(ms); clock(ms);
} }
wxLog::FlushActive();
} }
} }
catch (std::exception& e) { catch (std::exception& e) {

@ -297,6 +297,8 @@ void *CDStarRepeaterTRXThread::Entry()
} else { } else {
clock(ms); clock(ms);
} }
wxLog::FlushActive();
} }
} }
catch (std::exception& e) { catch (std::exception& e) {

@ -138,6 +138,8 @@ void *CDStarRepeaterTXThread::Entry()
} else { } else {
clock(ms); clock(ms);
} }
wxLog::FlushActive();
} }
} }
catch (std::exception& e) { catch (std::exception& e) {

Loading…
Cancel
Save

Powered by TurnKey Linux.