[Companion][Simulator] Add custom qDebug message handler/formatter (#4475)

* [Companion][Simulator] Add custom qDebug message handler/formatter as an option. Keeps support for QT_MESSAGE_PATTERN env. var.

* [Simulator] Show system messages of level qInfo and above in debug console.

* [Simulator] Still capture screenshot to clipboard if path is not accessible (and screenshot results now print to simulator debug console).

* Fix for older CMake.

* [Companion] Do not start debug message handler if app is shutting down, and add null checks before using it; Increase backtrace report depth; Add OTx headers; Add Companion exit status debug; Clean up unused code.

* [Simulator] Add asynchronous FIFO buffer for handling debug output/display more efficiently. (#4488)
(cherry-picked from b12bd7d7be)
This commit is contained in:
Max Paperno
2017-03-02 18:35:00 +01:00
committed by Bertrand Songis
parent 620094e358
commit 00b2799427
14 changed files with 352 additions and 72 deletions
+5 -24
View File
@@ -24,7 +24,6 @@
#include <QLocale>
#include <QString>
#include <QDir>
#include <QDebug>
#include <QTextStream>
#include <QMessageBox>
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
@@ -33,6 +32,7 @@
#endif
#include "appdata.h"
#include "appdebugmessagehandler.h"
#include "constants.h"
#include "eeprominterface.h"
#include "simulator.h"
@@ -42,16 +42,6 @@
#include "qxtcommandoptions.h"
#include "version.h"
#ifdef WIN32
#include <windows.h>
#ifdef _MSC_VER
#define sleep(x) Sleep(x*1000)
#endif
#endif
#if !defined(_MSC_VER) || defined(__GNUC__)
#include <unistd.h>
#endif
using namespace Simulator;
int finish(int exitCode);
@@ -96,21 +86,15 @@ int main(int argc, char *argv[])
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
if (!GetConsoleWindow()) {
AllocConsole();
freopen("conin$", "r", stdin);
freopen("conout$", "w", stdout);
freopen("conout$", "w", stderr);
}
SetConsoleTitle(APP_SIMULATOR " Console");
#endif
QApplication app(argc, argv);
app.setApplicationName(APP_SIMULATOR);
app.setOrganizationName(COMPANY);
app.setOrganizationDomain(COMPANY_DOMAIN);
if (AppDebugMessageHandler::instance())
AppDebugMessageHandler::instance()->installAppMessageHandler();
g.init();
QTranslator companionTranslator;
@@ -219,7 +203,7 @@ int main(int argc, char *argv[])
return finish(0);
}
}
qDebug() << __FILE__ << __LINE__ << "profileId=" << profileId << simOptions;
qDebug() << "profileId=" << profileId << simOptions;
if (profileId < 0 || simOptions.firmwareId.isEmpty() || (simOptions.dataFile.isEmpty() && simOptions.dataFolder.isEmpty())) {
showMessage(QObject::tr("ERROR: Couldn't start simulator, missing radio/profile/data file/folder.\n Profile ID: [%1]; Radio ID: [%2];\nData File: [%3]")
@@ -277,9 +261,6 @@ int finish(int exitCode)
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
SDL_Quit();
#endif
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
FreeConsole();
#endif
return exitCode;
}