[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
@@ -33,6 +33,7 @@
|
||||
#endif
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
|
||||
@@ -69,6 +70,14 @@ SimulatorMainWindow::SimulatorMainWindow(QWidget *parent, const QString & firmwa
|
||||
return;
|
||||
}
|
||||
|
||||
if (g.fwTraceLog() && !g.appLogsDir().isEmpty() && QDir().mkpath(g.appLogsDir())) {
|
||||
// send firmware TRACE events to log file
|
||||
QString fn = g.appLogsDir() % "/FirmwareDebug_" % QDateTime::currentDateTime().toString("yy-MM-dd_HH-mm-ss") % ".log";
|
||||
m_simuLogFile.setFileName(fn);
|
||||
if (m_simuLogFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
m_simulator->addTracebackDevice(&m_simuLogFile);
|
||||
}
|
||||
|
||||
m_simulator->moveToThread(&simuThread);
|
||||
simuThread.start();
|
||||
|
||||
@@ -140,8 +149,6 @@ SimulatorMainWindow::SimulatorMainWindow(QWidget *parent, const QString & firmwa
|
||||
connect(ui->actionScreenshot, &QAction::triggered, m_simulatorWidget, &SimulatorWidget::captureScreenshot);
|
||||
connect(m_simulatorWidget, &SimulatorWidget::windowTitleChanged, this, &SimulatorMainWindow::setWindowTitle);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
SimulatorMainWindow::~SimulatorMainWindow()
|
||||
@@ -164,6 +171,10 @@ SimulatorMainWindow::~SimulatorMainWindow()
|
||||
if (m_simulator) {
|
||||
simuThread.quit();
|
||||
simuThread.wait();
|
||||
if (m_simuLogFile.isOpen()) {
|
||||
m_simulator->removeTracebackDevice(&m_simuLogFile);
|
||||
m_simuLogFile.close();
|
||||
}
|
||||
delete m_simulator;
|
||||
}
|
||||
SimulatorLoader::unloadSimulator(m_simulatorId);
|
||||
|
||||
Reference in New Issue
Block a user