From d23b2a374cd3fd1fe834deb2cee7609ea1cfb3f4 Mon Sep 17 00:00:00 2001 From: Christoph Kottke Date: Fri, 7 Jun 2019 07:39:18 +0200 Subject: [PATCH] add debug logging switch --- DStarRepeater/DStarRepeaterApp.cpp | 12 ++++++++++++ DStarRepeater/DStarRepeaterApp.h | 1 + DStarRepeater/DStarRepeaterRXThread.cpp | 2 ++ DStarRepeater/DStarRepeaterTRXThread.cpp | 2 ++ DStarRepeater/DStarRepeaterTXThread.cpp | 2 ++ 5 files changed, 19 insertions(+) diff --git a/DStarRepeater/DStarRepeaterApp.cpp b/DStarRepeater/DStarRepeaterApp.cpp index 07e5d72..f6d54b4 100644 --- a/DStarRepeater/DStarRepeaterApp.cpp +++ b/DStarRepeater/DStarRepeaterApp.cpp @@ -63,6 +63,7 @@ wxEND_EVENT_TABLE() const wxString NAME_PARAM = "Repeater Name"; const wxString NOLOGGING_SWITCH = "nolog"; +const wxString DEBUG_SWITCH = "debug"; const wxString GUI_SWITCH = "gui"; const wxString LOGDIR_OPTION = "logdir"; const wxString CONFDIR_OPTION = "confdir"; @@ -80,6 +81,7 @@ m_frame(NULL), #endif m_name(), m_nolog(false), +m_debug(false), m_gui(false), m_logDir(), m_confDir(), @@ -120,6 +122,14 @@ bool CDStarRepeaterApp::OnInit() try { CLogger* log = new CLogger(m_logDir, logBaseName); 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 ) { wxLog::SetActiveTarget(new wxLogStderr()); wxLogError("Could not open log file, logging to stderr"); @@ -218,6 +228,7 @@ int CDStarRepeaterApp::OnExit() void CDStarRepeaterApp::OnInitCmdLine(wxCmdLineParser& parser) { 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.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); @@ -233,6 +244,7 @@ bool CDStarRepeaterApp::OnCmdLineParsed(wxCmdLineParser& parser) return false; m_nolog = parser.Found(NOLOGGING_SWITCH); + m_debug = parser.Found(DEBUG_SWITCH); m_gui = parser.Found(GUI_SWITCH); wxString logDir; diff --git a/DStarRepeater/DStarRepeaterApp.h b/DStarRepeater/DStarRepeaterApp.h index 6c29dc8..c5f6e58 100644 --- a/DStarRepeater/DStarRepeaterApp.h +++ b/DStarRepeater/DStarRepeaterApp.h @@ -68,6 +68,7 @@ private: wxString m_name; bool m_nolog; + bool m_debug; bool m_gui; wxString m_logDir; wxString m_confDir; diff --git a/DStarRepeater/DStarRepeaterRXThread.cpp b/DStarRepeater/DStarRepeaterRXThread.cpp index 28cf810..a319d85 100644 --- a/DStarRepeater/DStarRepeaterRXThread.cpp +++ b/DStarRepeater/DStarRepeaterRXThread.cpp @@ -101,6 +101,8 @@ void *CDStarRepeaterRXThread::Entry() } else { clock(ms); } + + wxLog::FlushActive(); } } catch (std::exception& e) { diff --git a/DStarRepeater/DStarRepeaterTRXThread.cpp b/DStarRepeater/DStarRepeaterTRXThread.cpp index f238001..837f8b7 100644 --- a/DStarRepeater/DStarRepeaterTRXThread.cpp +++ b/DStarRepeater/DStarRepeaterTRXThread.cpp @@ -297,6 +297,8 @@ void *CDStarRepeaterTRXThread::Entry() } else { clock(ms); } + + wxLog::FlushActive(); } } catch (std::exception& e) { diff --git a/DStarRepeater/DStarRepeaterTXThread.cpp b/DStarRepeater/DStarRepeaterTXThread.cpp index 062b991..d656df8 100644 --- a/DStarRepeater/DStarRepeaterTXThread.cpp +++ b/DStarRepeater/DStarRepeaterTXThread.cpp @@ -138,6 +138,8 @@ void *CDStarRepeaterTXThread::Entry() } else { clock(ms); } + + wxLog::FlushActive(); } } catch (std::exception& e) {