Commit f488360d authored by Don Gagne's avatar Don Gagne

Merge pull request #1656 from DonLakeFlyer/LogCommandLine

--full-logging command line option
parents c7a820a3 b974dff7
...@@ -147,46 +147,61 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) ...@@ -147,46 +147,61 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
#ifndef __android__ #ifndef __android__
setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif #endif
// Parse command line options
bool fClearSettingsOptions = false; // Clear stored settings
bool fullLogging = false; // Turn on all logging
CmdLineOpt_t rgCmdLineOptions[] = {
{ "--clear-settings", &fClearSettingsOptions, QString() },
{ "--full-logging", &fullLogging, QString() },
// Add additional command line option flags here
};
ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false);
#ifdef __mobile__ #ifdef __mobile__
QLoggingCategory::setFilterRules(QStringLiteral("*Log.debug=false")); QLoggingCategory::setFilterRules(QStringLiteral("*Log.debug=false"));
#endif #else
if (fullLogging) {
#ifndef __mobile__ QLoggingCategory::setFilterRules(QStringLiteral("*Log=true"));
// First thing we want to do is set up the qtlogging.ini file. If it doesn't already exist we copy } else {
// it to the correct location. This way default debug builds will have logging turned off. // First thing we want to do is set up the qtlogging.ini file. If it doesn't already exist we copy
// it to the correct location. This way default debug builds will have logging turned off.
static const char* qtProjectDir = "QtProject"; static const char* qtProjectDir = "QtProject";
static const char* qtLoggingFile = "qtlogging.ini"; static const char* qtLoggingFile = "qtlogging.ini";
bool loggingDirectoryOk = false; bool loggingDirectoryOk = false;
QDir iniFileLocation(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); QDir iniFileLocation(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
if (!iniFileLocation.cd(qtProjectDir)) { if (!iniFileLocation.cd(qtProjectDir)) {
if (!iniFileLocation.mkdir(qtProjectDir)) { if (!iniFileLocation.mkdir(qtProjectDir)) {
qDebug() << "Unable to create qtlogging.ini directory" << iniFileLocation.filePath(qtProjectDir); qDebug() << "Unable to create qtlogging.ini directory" << iniFileLocation.filePath(qtProjectDir);
} else { } else {
if (!iniFileLocation.cd(qtProjectDir)) { if (!iniFileLocation.cd(qtProjectDir)) {
qDebug() << "Unable to access qtlogging.ini directory" << iniFileLocation.filePath(qtProjectDir);; qDebug() << "Unable to access qtlogging.ini directory" << iniFileLocation.filePath(qtProjectDir);;
}
loggingDirectoryOk = true;
} }
} else {
loggingDirectoryOk = true; loggingDirectoryOk = true;
} }
} else {
loggingDirectoryOk = true;
}
if (loggingDirectoryOk) { if (loggingDirectoryOk) {
qDebug () << iniFileLocation; qDebug () << iniFileLocation;
if (!iniFileLocation.exists(qtLoggingFile)) { if (!iniFileLocation.exists(qtLoggingFile)) {
QFile loggingFile(iniFileLocation.filePath(qtLoggingFile)); QFile loggingFile(iniFileLocation.filePath(qtLoggingFile));
if (loggingFile.open(QIODevice::WriteOnly | QIODevice::Text)) { if (loggingFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream out(&loggingFile); QTextStream out(&loggingFile);
out << "[Rules]\n"; out << "[Rules]\n";
out << "*Log.debug=false\n"; out << "*Log.debug=false\n";
foreach(QString category, QGCLoggingCategoryRegister::instance()->registeredCategories()) { foreach(QString category, QGCLoggingCategoryRegister::instance()->registeredCategories()) {
out << category << ".debug=false\n"; out << category << ".debug=false\n";
}
} else {
qDebug() << "Unable to create logging file" << QString(qtLoggingFile) << "in" << iniFileLocation;
} }
} else {
qDebug() << "Unable to create logging file" << QString(qtLoggingFile) << "in" << iniFileLocation;
} }
} }
} }
...@@ -217,17 +232,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) ...@@ -217,17 +232,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
// Set settings format // Set settings format
QSettings::setDefaultFormat(QSettings::IniFormat); QSettings::setDefaultFormat(QSettings::IniFormat);
// Parse command line options
bool fClearSettingsOptions = false; // Clear stored settings
CmdLineOpt_t rgCmdLineOptions[] = {
{ "--clear-settings", &fClearSettingsOptions, QString() },
// Add additional command line option flags here
};
ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false);
QSettings settings; QSettings settings;
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
qDebug() << "Settings location" << settings.fileName(); qDebug() << "Settings location" << settings.fileName();
......
...@@ -459,6 +459,8 @@ void LinkManager::_updateConfigurationList(void) ...@@ -459,6 +459,8 @@ void LinkManager::_updateConfigurationList(void)
QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts(); QList<QSerialPortInfo> portList = QSerialPortInfo::availablePorts();
// Iterate Comm Ports // Iterate Comm Ports
foreach (QSerialPortInfo portInfo, portList) { foreach (QSerialPortInfo portInfo, portList) {
#if 0
// Too noisy for most logging, so turn on as needed
qCDebug(LinkManagerLog) << "-----------------------------------------------------"; qCDebug(LinkManagerLog) << "-----------------------------------------------------";
qCDebug(LinkManagerLog) << "portName: " << portInfo.portName(); qCDebug(LinkManagerLog) << "portName: " << portInfo.portName();
qCDebug(LinkManagerLog) << "systemLocation: " << portInfo.systemLocation(); qCDebug(LinkManagerLog) << "systemLocation: " << portInfo.systemLocation();
...@@ -466,6 +468,7 @@ void LinkManager::_updateConfigurationList(void) ...@@ -466,6 +468,7 @@ void LinkManager::_updateConfigurationList(void)
qCDebug(LinkManagerLog) << "manufacturer: " << portInfo.manufacturer(); qCDebug(LinkManagerLog) << "manufacturer: " << portInfo.manufacturer();
qCDebug(LinkManagerLog) << "serialNumber: " << portInfo.serialNumber(); qCDebug(LinkManagerLog) << "serialNumber: " << portInfo.serialNumber();
qCDebug(LinkManagerLog) << "vendorIdentifier: " << portInfo.vendorIdentifier(); qCDebug(LinkManagerLog) << "vendorIdentifier: " << portInfo.vendorIdentifier();
#endif
// Save port name // Save port name
currentPorts << portInfo.systemLocation(); currentPorts << portInfo.systemLocation();
// Is this a PX4 and NOT in bootloader mode? // Is this a PX4 and NOT in bootloader mode?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment