diff --git a/files/QLoggingCategory/qtlogging.ini b/files/QLoggingCategory/qtlogging.ini
deleted file mode 100644
index c67fdd4cf2ace3d3b61f16e05690bfc50a237b0b..0000000000000000000000000000000000000000
--- a/files/QLoggingCategory/qtlogging.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[Rules]
-*Log=false
diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index d3be1b28f5cad4e7ec48c35e8f4f67659dde9cbb..2e69c09268d6f9e07cf7a21b66f501758a8d7882 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -497,7 +497,8 @@ HEADERS += \
src/ui/QGCUDPLinkConfiguration.h \
src/uas/UASMessageHandler.h \
src/ui/toolbar/MainToolBar.h \
- src/QmlControls/ScreenTools.h
+ src/QmlControls/ScreenTools.h \
+ src/QGCLoggingCategory.h
SOURCES += \
src/main.cc \
@@ -639,7 +640,8 @@ SOURCES += \
src/ui/QGCUDPLinkConfiguration.cc \
src/uas/UASMessageHandler.cc \
src/ui/toolbar/MainToolBar.cc \
- src/QmlControls/ScreenTools.cc
+ src/QmlControls/ScreenTools.cc \
+ src/QGCLoggingCategory.cc
#
# Unit Test specific configuration goes here
diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index 48ec2158367e718c3538cca3259981160dffa658..98f550c8a5c0cb1b5e5ba684b98c3bd2568270a1 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -241,9 +241,6 @@
src/qgcunittest/MockLink.param
src/FactSystem/FactSystemTest.qml
-
- files/QLoggingCategory/qtlogging.ini
-
src/test.qml
src/QmlControls/QmlTest.qml
diff --git a/src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc b/src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc
index a7fdf87ac74cf1624840a34bcccedeaac6f0d932..5a055114869b55bcac6b09e105f73956affea028 100644
--- a/src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc
+++ b/src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc
@@ -26,11 +26,12 @@
#include "PX4ParameterFacts.h"
#include "QGCApplication.h"
+#include "QGCLoggingCategory.h"
#include
#include
-Q_LOGGING_CATEGORY(PX4ParameterFactsMetaDataLog, "PX4ParameterFactsMetaDataLog")
+QGC_LOGGING_CATEGORY(PX4ParameterFactsMetaDataLog, "PX4ParameterFactsMetaDataLog")
bool PX4ParameterFacts::_parameterMetaDataLoaded = false;
QMap PX4ParameterFacts::_mapParameterName2FactMetaData;
diff --git a/src/FactSystem/FactLoader.cc b/src/FactSystem/FactLoader.cc
index 394d7fb374ace5ddedc0af62e897e2e1e3e6c942..3b207542a1b30048e673313226c15d511dc3e3f0 100644
--- a/src/FactSystem/FactLoader.cc
+++ b/src/FactSystem/FactLoader.cc
@@ -26,11 +26,12 @@
#include "FactLoader.h"
#include "QGCApplication.h"
+#include "QGCLoggingCategory.h"
#include
#include
-Q_LOGGING_CATEGORY(FactLoaderLog, "FactLoaderLog")
+QGC_LOGGING_CATEGORY(FactLoaderLog, "FactLoaderLog")
FactLoader::FactLoader(UASInterface* uas, QObject* parent) :
QObject(parent),
diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc
index df3d9e272f359697c90750d6e8ecf32dd80109eb..03271b21f03bcda036bf2c37779570f898cbd722 100644
--- a/src/QGCApplication.cc
+++ b/src/QGCApplication.cc
@@ -60,6 +60,7 @@
#include "QGCFileDialog.h"
#include "QGCPalette.h"
#include "ScreenTools.h"
+#include "QGCLoggingCategory.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
@@ -128,8 +129,16 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
if (loggingDirectoryOk) {
qDebug () << iniFileLocation;
if (!iniFileLocation.exists(qtLoggingFile)) {
- if (!QFile::copy(":QLoggingCategory/qtlogging.ini", iniFileLocation.filePath(qtLoggingFile))) {
- qDebug() << "Unable to copy" << QString(qtLoggingFile) << "to" << iniFileLocation;
+ QFile loggingFile(iniFileLocation.filePath(qtLoggingFile));
+ if (loggingFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ QTextStream out(&loggingFile);
+ out << "[Rules]\n";
+ out << "*Log=false\n";
+ foreach(QString category, QGCLoggingCategoryRegister::instance()->registeredCategories()) {
+ out << category << "=false\n";
+ }
+ } else {
+ qDebug() << "Unable to create logging file" << QString(qtLoggingFile) << "in" << iniFileLocation;
}
}
}
diff --git a/src/QGCLoggingCategory.cc b/src/QGCLoggingCategory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7a7c3cdaeb62ad7056e963391913212f4fc6744c
--- /dev/null
+++ b/src/QGCLoggingCategory.cc
@@ -0,0 +1,42 @@
+/*=====================================================================
+
+ QGroundControl Open Source Ground Control Station
+
+ (c) 2009 - 2015 QGROUNDCONTROL PROJECT
+
+ This file is part of the QGROUNDCONTROL project
+
+ QGROUNDCONTROL is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ QGROUNDCONTROL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QGROUNDCONTROL. If not, see .
+
+ ======================================================================*/
+
+/// @file
+/// @author Don Gagne
+
+#include "QGCLoggingCategory.h"
+
+// Add Global logging categories (not class specific) here using QGC_LOGGING_CATEGORY
+ // There currently are no global categories
+
+QGCLoggingCategoryRegister* _instance = NULL;
+
+QGCLoggingCategoryRegister* QGCLoggingCategoryRegister::instance(void)
+{
+ if (!_instance) {
+ _instance = new QGCLoggingCategoryRegister();
+ Q_CHECK_PTR(_instance);
+ }
+
+ return _instance;
+}
diff --git a/src/QGCLoggingCategory.h b/src/QGCLoggingCategory.h
new file mode 100644
index 0000000000000000000000000000000000000000..e059f833dd0567c8edbc82e8fd152e30e968ec51
--- /dev/null
+++ b/src/QGCLoggingCategory.h
@@ -0,0 +1,63 @@
+/*=====================================================================
+
+ QGroundControl Open Source Ground Control Station
+
+ (c) 2009 - 2015 QGROUNDCONTROL PROJECT
+
+ This file is part of the QGROUNDCONTROL project
+
+ QGROUNDCONTROL is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ QGROUNDCONTROL is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QGROUNDCONTROL. If not, see .
+
+ ======================================================================*/
+
+/// @file
+/// @author Don Gagne
+
+#ifndef QGC_LOGGING_CATEGORY_H
+#define QGC_LOGGING_CATEGORY_H
+
+#include
+#include
+
+// Add Global logging categories (not class specific) here using Q_DECLARE_LOGGING_CATEGORY
+ // There currently are no global categories
+
+/// @def QGC_LOGGING_CATEGORY
+/// This is a QGC specific replacement for Q_LOGGING_CATEGORY. It will register the category name into a
+/// global list. It's usage is the same as Q_LOGGING_CATEOGRY.
+#define QGC_LOGGING_CATEGORY(name, ...) \
+ static QGCLoggingCategory qgcCategory(__VA_ARGS__); \
+ Q_LOGGING_CATEGORY(name, __VA_ARGS__)
+
+class QGCLoggingCategoryRegister
+{
+public:
+ static QGCLoggingCategoryRegister* instance(void);
+
+ void registerCategory(const char* category) { _registeredCategories << category; }
+ const QStringList& registeredCategories(void) { return _registeredCategories; }
+
+private:
+ QGCLoggingCategoryRegister(void) { }
+
+ QStringList _registeredCategories;
+};
+
+class QGCLoggingCategory
+{
+public:
+ QGCLoggingCategory(const char* category) { QGCLoggingCategoryRegister::instance()->registerCategory(category); }
+};
+
+#endif
diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc
index 5922b558560f1ecdfa6bca388cdd56ff8eb33eee..3986d027719cdb1ebfa77c6bf480d3c8b63779ab 100644
--- a/src/comm/MAVLinkProtocol.cc
+++ b/src/comm/MAVLinkProtocol.cc
@@ -29,10 +29,11 @@
#include "QGCMAVLinkUASFactory.h"
#include "QGC.h"
#include "QGCApplication.h"
+#include "QGCLoggingCategory.h"
Q_DECLARE_METATYPE(mavlink_message_t)
IMPLEMENT_QGC_SINGLETON(MAVLinkProtocol, MAVLinkProtocol)
-Q_LOGGING_CATEGORY(MAVLinkProtocolLog, "MAVLinkProtocolLog")
+QGC_LOGGING_CATEGORY(MAVLinkProtocolLog, "MAVLinkProtocolLog")
const char* MAVLinkProtocol::_tempLogFileTemplate = "FlightDataXXXXXX"; ///< Template for temporary log file
const char* MAVLinkProtocol::_logFileExtension = "mavlink"; ///< Extension for log files
diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc
index 8a656df04cc332a0bf3c3afb53c9f29c33bd5d57..91481d360d12dee26cf799e31d698e4122bcaa52 100644
--- a/src/comm/SerialLink.cc
+++ b/src/comm/SerialLink.cc
@@ -18,8 +18,9 @@
#include "SerialLink.h"
#include "QGC.h"
#include "MG.h"
+#include "QGCLoggingCategory.h"
-Q_LOGGING_CATEGORY(SerialLinkLog, "SerialLinkLog")
+QGC_LOGGING_CATEGORY(SerialLinkLog, "SerialLinkLog")
SerialLink::SerialLink(SerialConfiguration* config)
{
diff --git a/src/qgcunittest/MockLink.cc b/src/qgcunittest/MockLink.cc
index d348aac67a7fb9de91e5746acbc1fc1be1b7f0e9..7513baa0b595b5d9f071504194acb47353e11abe 100644
--- a/src/qgcunittest/MockLink.cc
+++ b/src/qgcunittest/MockLink.cc
@@ -22,6 +22,7 @@
======================================================================*/
#include "MockLink.h"
+#include "QGCLoggingCategory.h"
#include
#include
@@ -29,7 +30,7 @@
#include
-Q_LOGGING_CATEGORY(MockLinkLog, "MockLinkLog")
+QGC_LOGGING_CATEGORY(MockLinkLog, "MockLinkLog")
/// @file
/// @brief Mock implementation of a Link.
diff --git a/src/qgcunittest/MockQGCUASParamManager.cc b/src/qgcunittest/MockQGCUASParamManager.cc
index e8e574ecbd07063e07a40044e1b2070983059a6f..77b751b3d43ade3d3f341e6ca1ad964a74cc87b1 100644
--- a/src/qgcunittest/MockQGCUASParamManager.cc
+++ b/src/qgcunittest/MockQGCUASParamManager.cc
@@ -23,11 +23,12 @@
#include "MockQGCUASParamManager.h"
#include "mavlink.h"
+#include "QGCLoggingCategory.h"
#include
#include
-Q_LOGGING_CATEGORY(MockQGCUASParamManagerLog, "MockQGCUASParamManagerLog")
+QGC_LOGGING_CATEGORY(MockQGCUASParamManagerLog, "MockQGCUASParamManagerLog")
MockQGCUASParamManager::MockQGCUASParamManager(void)
{
diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc
index c4dbbcb3f1478050ec54f735972140538fbb881c..afcd11b6d31fcb898fb0e2cfc32f37af5887ba30 100644
--- a/src/uas/UAS.cc
+++ b/src/uas/UAS.cc
@@ -31,8 +31,9 @@
#include
#include "AutoPilotPluginManager.h"
#include "QGCMessageBox.h"
+#include "QGCLoggingCategory.h"
-Q_LOGGING_CATEGORY(UASLog, "UASLog")
+QGC_LOGGING_CATEGORY(UASLog, "UASLog")
#define UAS_DEFAULT_BATTERY_WARNLEVEL 20
diff --git a/src/uas/UASParameterCommsMgr.cc b/src/uas/UASParameterCommsMgr.cc
index 83ee8950f81ad4a8923c637de06991c25f836e6e..94f06ec980a1f1c0226c20e5b473c24a2c1cda72 100644
--- a/src/uas/UASParameterCommsMgr.cc
+++ b/src/uas/UASParameterCommsMgr.cc
@@ -7,10 +7,11 @@
#include "UASInterface.h"
#include "MAVLinkProtocol.h"
#include "MainWindow.h"
+#include "QGCLoggingCategory.h"
#define RC_CAL_CHAN_MAX 8
-Q_LOGGING_CATEGORY(UASParameterCommsMgrLog, "UASParameterCommsMgrLog")
+QGC_LOGGING_CATEGORY(UASParameterCommsMgrLog, "UASParameterCommsMgrLog")
UASParameterCommsMgr::UASParameterCommsMgr(QObject *parent) :
QObject(parent),