[Companion] Add optional logging of all debug output. (#4974)
* [AppDebugMessageHandler] Add ability to write debug output to any number of QIODevices. * [Simulator][DebugOutput] Use new QIODevice hook in AppDebugMessageHandler instead of signal/slot. * [AppData] Add new settings for debug logging; Refactor property creation macro to work with any data type and add varName_init() method to set default; Refactor all boolean settings to use new macro (others to be migrated later). * [AppPreferencesDialog] Add UI for appDebugLog, fwTraceLog, & appLogsDir settings; Clean up layout on application prefs. tab, move and re-label a couple items. * [Companion][Simulator] Enable optional application debug output logging. * [Simulator] Enable optional logging of firmware debug output to file. * [EEPROMInterface] Use qDebug() instead of std::cout so that now all debug output can be routed via custom message handler/logger. * [Companion][Simulator] Add missing #include.
This commit is contained in:
committed by
Bertrand Songis
parent
2e4775b19a
commit
f50ee3fb39
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDateTime>
|
||||
#include <QCommandLineParser>
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
@@ -42,6 +43,7 @@
|
||||
|
||||
using namespace Simulator;
|
||||
|
||||
QFile simuDbgLog;
|
||||
int finish(int exitCode);
|
||||
|
||||
void showMessage(const QString & message, enum QMessageBox::Icon icon = QMessageBox::NoIcon, bool useConsole = false)
|
||||
@@ -56,10 +58,9 @@ void showMessage(const QString & message, enum QMessageBox::Icon icon = QMessage
|
||||
}
|
||||
// use GUI
|
||||
QMessageBox msgBox;
|
||||
QString escMsg(message);
|
||||
escMsg.replace("<", "<");
|
||||
msgBox.setText("<html><body><pre>" + escMsg + "</pre></body></html>");
|
||||
msgBox.setText("<html><body><pre>" + message.toHtmlEscaped() + "</pre></body></html>");
|
||||
msgBox.setIcon(icon);
|
||||
msgBox.setWindowTitle(QApplication::translate("SimulatorMain", "OpenTx Simulator"));
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
@@ -251,6 +252,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
g.init(); // init settings before installing translations
|
||||
|
||||
if (AppDebugMessageHandler::instance() && g.appDebugLog() && !g.appLogsDir().isEmpty() && QDir().mkpath(g.appLogsDir())) {
|
||||
QString fn = g.appLogsDir() % "/SimulatorDebug_" % QDateTime::currentDateTime().toString("yy-MM-dd_HH-mm-ss") % ".log";
|
||||
simuDbgLog.setFileName(fn);
|
||||
if (simuDbgLog.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
AppDebugMessageHandler::instance()->addOutputDevice(&simuDbgLog);
|
||||
}
|
||||
}
|
||||
|
||||
Translations::installTranslators();
|
||||
|
||||
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
|
||||
@@ -365,5 +374,9 @@ int finish(int exitCode)
|
||||
#endif
|
||||
|
||||
qDebug() << "SIMULATOR EXIT" << exitCode;
|
||||
if (simuDbgLog.isOpen()) {
|
||||
AppDebugMessageHandler::instance()->removeOutputDevice(&simuDbgLog);
|
||||
simuDbgLog.close();
|
||||
}
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user