From a0ec163a9c61b7cf99eb58576b33964ad5301575 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Wed, 16 Apr 2014 10:58:40 +0000 Subject: [PATCH] Made trace file for Qt debugging output a CMake build option. WSJT-X has a capability of redirecting Qt debugging output (qDebug, qWarning etc.) to a trace file 'wsjtx_trace.log' which is created in the application run directory if not already present. Setting the CMake build option WSJT_QDEBUG_TO_FILE to ON will enable this feature. It should be noted that this option is not compatible with a distributibutable official release since writing to the application directory is not recommended. Also in a full Release configuration build all Qt debugging code is elided so no useful trace would be obtained anyway. The CMake option WSJT_QDEBUG_IN_RELEASE may be useful in concert with this option as it causes Qt debugging statements to remain in place in a Release build configuration. Again not recommended in a full Release build since the debugging code both slows down the application and adds unecessary bloat to the executable size. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4032 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- CMakeLists.txt | 3 ++- main.cpp | 8 +++++--- wsjtx_config.h.in | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee67a7c0d..56fbac20e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,8 @@ include (${PROJECT_SOURCE_DIR}/CMake/VersionCompute.cmake) option (UPDATE_TRANSLATIONS "Update source translation translations/*.ts files (WARNING: make clean will delete the source .ts files! Danger!)") option (WSJT_SHARED_RUNTIME "Debugging option that allows running from a shared Cloud directory.") -option (WSJT_QDEBUG_IN_RELEASE "Leave qDebug statements in Release configuration.") +option (WSJT_QDEBUG_TO_FILE "Redirect Qt debuging messages to a trace file.") +option (WSJT_QDEBUG_IN_RELEASE "Leave Qt debugging statements in Release configuration.") option (WSJT_TRACE_CAT "Debugging option that turns on CAT diagnostics.") option (WSJT_TRACE_CAT_POLLS "Debugging option that turns on CAT diagnostics during polling.") option (WSJT_HAMLIB_TRACE "Debugging option that turns on full Hamlib internal diagnostics.") diff --git a/main.cpp b/main.cpp index 937c887ed..eee2c5a38 100644 --- a/main.cpp +++ b/main.cpp @@ -74,11 +74,13 @@ int main(int argc, char *argv[]) } QSettings settings(config_path.absoluteFilePath (a.applicationName () + ".ini"), QSettings::IniFormat); +#if WSJT_QDEBUG_TO_FILE // // open a trace file - // TraceFile trace_file {QDir {QApplication::applicationDirPath ()}.absoluteFilePath ("wsjtx_trace.log")}; + TraceFile trace_file {QDir {QApplication::applicationDirPath ()}.absoluteFilePath ("wsjtx_trace.log")}; - // // announce to log file - // qDebug () << program_title (revision ()) + " - Program startup"; + // announce to trace file + qDebug () << program_title (revision ()) + " - Program startup"; +#endif // Create and initialize shared memory segment // Multiple instances: use rig_name as shared memory key diff --git a/wsjtx_config.h.in b/wsjtx_config.h.in index 0d388e77c..0d2769b57 100644 --- a/wsjtx_config.h.in +++ b/wsjtx_config.h.in @@ -17,6 +17,7 @@ #cmakedefine WSJT_DOC_DESTINATION "@WSJT_DOC_DESTINATION@" #cmakedefine01 WSJT_SHARED_RUNTIME +#cmakedefine01 WSJT_QDEBUG_TO_FILE #cmakedefine01 WSJT_QDEBUG_IN_RELEASE #cmakedefine01 WSJT_TRACE_CAT #cmakedefine01 WSJT_TRACE_CAT_POLLS