Merge PR #307: Loggingcategories
This commit is contained in:
commit
bd0072e48f
@ -37,6 +37,8 @@
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
NYMEA_LOGGING_CATEGORY(dcConfiguration, "Configuration")
|
||||
|
||||
namespace nymeaserver {
|
||||
|
||||
NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
@ -55,11 +57,11 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
tmpId.insert(23, "-");
|
||||
setServerUuid(QUuid(tmpId));
|
||||
} else {
|
||||
qWarning(dcApplication()) << "Failed to open /etc/machine-id for reading. Generating a new UUID for this server instance.";
|
||||
qWarning(dcConfiguration()) << "Failed to open /etc/machine-id for reading. Generating a new UUID for this server instance.";
|
||||
setServerUuid(QUuid::createUuid());
|
||||
}
|
||||
}
|
||||
qCDebug(dcApplication()) << "System UUID is:" << serverUuid().toString();
|
||||
qCDebug(dcConfiguration()) << "System UUID is:" << serverUuid().toString();
|
||||
|
||||
// Make sure default values are in configuration file so that it's easier for users to modify
|
||||
setServerName(serverName());
|
||||
@ -76,7 +78,7 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
if (settings.childGroups().contains("TcpServer")) {
|
||||
settings.beginGroup("TcpServer");
|
||||
if (settings.value("disabled").toBool()) {
|
||||
qCDebug(dcApplication) << "TCP server disabled by configuration";
|
||||
qCDebug(dcConfiguration) << "TCP server disabled by configuration";
|
||||
} else if (!settings.childGroups().isEmpty()) {
|
||||
foreach (const QString &key, settings.childGroups()) {
|
||||
ServerConfiguration config = readServerConfig("TcpServer", key);
|
||||
@ -88,7 +90,7 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
settings.endGroup();
|
||||
}
|
||||
if (createDefaults) {
|
||||
qCWarning(dcApplication) << "No TCP server configuration found. Generating default of nymeas://0.0.0.0:2222";
|
||||
qCWarning(dcConfiguration) << "No TCP server configuration found. Generating default of nymeas://0.0.0.0:2222";
|
||||
ServerConfiguration config;
|
||||
config.id = "default";
|
||||
config.address = QHostAddress("0.0.0.0");
|
||||
@ -104,7 +106,7 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
if (settings.childGroups().contains("WebServer")) {
|
||||
settings.beginGroup("WebServer");
|
||||
if (settings.value("disabled").toBool()) {
|
||||
qCDebug(dcApplication) << "Web server disabled by configuration";
|
||||
qCDebug(dcConfiguration) << "Web server disabled by configuration";
|
||||
} else if (!settings.childGroups().isEmpty()) {
|
||||
foreach (const QString &key, settings.childGroups()) {
|
||||
WebServerConfiguration config = readWebServerConfig(key);
|
||||
@ -116,7 +118,7 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
settings.endGroup();
|
||||
}
|
||||
if (createDefaults) {
|
||||
qCWarning(dcApplication) << "No Web server configuration found. Generating defaults of http://0.0.0.0:80 and https://0.0.0.0:443";
|
||||
qCWarning(dcConfiguration) << "No Web server configuration found. Generating defaults of http://0.0.0.0:80 and https://0.0.0.0:443";
|
||||
WebServerConfiguration insecureConfig;
|
||||
insecureConfig.id = "insecure";
|
||||
insecureConfig.address = QHostAddress("0.0.0.0");
|
||||
@ -145,7 +147,7 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
if (settings.childGroups().contains("WebSocketServer")) {
|
||||
settings.beginGroup("WebSocketServer");
|
||||
if (settings.value("disabled").toBool()) {
|
||||
qCDebug(dcApplication) << "WebSocket server disabled by configuration.";
|
||||
qCDebug(dcConfiguration) << "WebSocket server disabled by configuration.";
|
||||
} else if (!settings.childGroups().isEmpty()) {
|
||||
foreach (const QString &key, settings.childGroups()) {
|
||||
ServerConfiguration config = readServerConfig("WebSocketServer", key);
|
||||
@ -157,7 +159,7 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
settings.endGroup();
|
||||
}
|
||||
if (createDefaults) {
|
||||
qCWarning(dcApplication) << "No WebSocket server configuration found. Generating default of wss://0.0.0.0:4444";
|
||||
qCWarning(dcConfiguration) << "No WebSocket server configuration found. Generating default of wss://0.0.0.0:4444";
|
||||
ServerConfiguration config;
|
||||
config.id = "default";
|
||||
config.address = QHostAddress("0.0.0.0");
|
||||
@ -173,7 +175,7 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
if (settings.childGroups().contains("MqttServer")) {
|
||||
settings.beginGroup("MqttServer");
|
||||
if (settings.value("disabled").toBool()) {
|
||||
qCDebug(dcApplication) << "MQTT server disabled by configuration.";
|
||||
qCDebug(dcConfiguration) << "MQTT server disabled by configuration.";
|
||||
} else if (!settings.childGroups().isEmpty()) {
|
||||
foreach (const QString &key, settings.childGroups()) {
|
||||
ServerConfiguration config = readServerConfig("MqttServer", key);
|
||||
@ -185,7 +187,7 @@ NymeaConfiguration::NymeaConfiguration(QObject *parent) :
|
||||
settings.endGroup();
|
||||
}
|
||||
if (createDefaults) {
|
||||
qCWarning(dcApplication) << "No MQTT server configuration found. Generating default of 0.0.0.0:1883";
|
||||
qCWarning(dcConfiguration) << "No MQTT server configuration found. Generating default of 0.0.0.0:1883";
|
||||
ServerConfiguration config;
|
||||
config.id = "default";
|
||||
config.address = QHostAddress("0.0.0.0");
|
||||
@ -236,12 +238,12 @@ QString NymeaConfiguration::serverName() const
|
||||
|
||||
void NymeaConfiguration::setServerName(const QString &serverName)
|
||||
{
|
||||
qCDebug(dcApplication()) << "Configuration: Server name:" << serverName;
|
||||
qCDebug(dcConfiguration()) << "Configuration: Server name:" << serverName;
|
||||
|
||||
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
|
||||
settings.beginGroup("nymead");
|
||||
if (settings.value("name").toString() == serverName) {
|
||||
qCDebug(dcApplication()) << "Configuration: Server name unchanged.";
|
||||
qCDebug(dcConfiguration()) << "Configuration: Server name unchanged.";
|
||||
settings.endGroup();
|
||||
} else {
|
||||
settings.setValue("name", serverName);
|
||||
@ -259,12 +261,12 @@ QByteArray NymeaConfiguration::timeZone() const
|
||||
|
||||
void NymeaConfiguration::setTimeZone(const QByteArray &timeZone)
|
||||
{
|
||||
qCDebug(dcApplication()) << "Configuration: Time zone:" << QString::fromUtf8(timeZone);
|
||||
qCDebug(dcConfiguration()) << "Configuration: Time zone:" << QString::fromUtf8(timeZone);
|
||||
|
||||
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
|
||||
settings.beginGroup("nymead");
|
||||
if (settings.value("timeZone").toByteArray() == timeZone) {
|
||||
qCDebug(dcApplication()) << "Configuration: Time zone unchanged.";
|
||||
qCDebug(dcConfiguration()) << "Configuration: Time zone unchanged.";
|
||||
settings.endGroup();
|
||||
} else {
|
||||
settings.setValue("timeZone", timeZone);
|
||||
@ -282,12 +284,12 @@ QLocale NymeaConfiguration::locale() const
|
||||
|
||||
void NymeaConfiguration::setLocale(const QLocale &locale)
|
||||
{
|
||||
qCDebug(dcApplication()) << "Configuration: Set system locale:" << locale.name() << locale.nativeCountryName() << locale.nativeLanguageName();
|
||||
qCDebug(dcConfiguration()) << "Configuration: Set system locale:" << locale.name() << locale.nativeCountryName() << locale.nativeLanguageName();
|
||||
|
||||
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
|
||||
settings.beginGroup("nymead");
|
||||
if (settings.value("language").toString() == locale.name()) {
|
||||
qCDebug(dcApplication()) << "Configuration: Language unchanged.";
|
||||
qCDebug(dcConfiguration()) << "Configuration: Language unchanged.";
|
||||
settings.endGroup();
|
||||
} else {
|
||||
settings.setValue("language", locale.name());
|
||||
@ -415,7 +417,7 @@ bool NymeaConfiguration::bluetoothServerEnabled() const
|
||||
|
||||
void NymeaConfiguration::setBluetoothServerEnabled(bool enabled)
|
||||
{
|
||||
qCDebug(dcApplication()) << "Configuration: Bluetooth server" << (enabled ? "enabled" : "disabled");
|
||||
qCDebug(dcConfiguration()) << "Configuration: Bluetooth server" << (enabled ? "enabled" : "disabled");
|
||||
|
||||
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
|
||||
settings.beginGroup("BluetoothServer");
|
||||
@ -585,7 +587,7 @@ bool NymeaConfiguration::debugServerEnabled() const
|
||||
|
||||
void NymeaConfiguration::setDebugServerEnabled(bool enabled)
|
||||
{
|
||||
qCDebug(dcApplication()) << "Configuration: Set debug server" << (enabled ? "enabled" : "disabled");
|
||||
qCDebug(dcConfiguration()) << "Configuration: Set debug server" << (enabled ? "enabled" : "disabled");
|
||||
bool currentValue = debugServerEnabled();
|
||||
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
|
||||
settings.beginGroup("nymead");
|
||||
@ -599,7 +601,7 @@ void NymeaConfiguration::setDebugServerEnabled(bool enabled)
|
||||
|
||||
void NymeaConfiguration::setServerUuid(const QUuid &uuid)
|
||||
{
|
||||
qCDebug(dcApplication()) << "Configuration: Server uuid:" << uuid.toString();
|
||||
qCDebug(dcConfiguration()) << "Configuration: Server uuid:" << uuid.toString();
|
||||
|
||||
NymeaSettings settings(NymeaSettings::SettingsRoleGlobal);
|
||||
settings.beginGroup("nymead");
|
||||
|
||||
@ -56,6 +56,8 @@
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
|
||||
NYMEA_LOGGING_CATEGORY(dcCore, "Core")
|
||||
|
||||
namespace nymeaserver {
|
||||
|
||||
NymeaCore* NymeaCore::s_instance = nullptr;
|
||||
@ -77,15 +79,15 @@ NymeaCore::NymeaCore(QObject *parent) :
|
||||
}
|
||||
|
||||
void NymeaCore::init() {
|
||||
qCDebug(dcApplication()) << "Initializing NymeaCore";
|
||||
qCDebug(dcCore()) << "Initializing NymeaCore";
|
||||
|
||||
qCDebug(dcPlatform()) << "Loading platform abstraction";
|
||||
m_platform = new Platform(this);
|
||||
|
||||
qCDebug(dcApplication()) << "Loading nymea configurations" << NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName();
|
||||
qCDebug(dcCore()) << "Loading nymea configurations" << NymeaSettings(NymeaSettings::SettingsRoleGlobal).fileName();
|
||||
m_configuration = new NymeaConfiguration(this);
|
||||
|
||||
qCDebug(dcApplication()) << "Creating Time Manager";
|
||||
qCDebug(dcCore()) << "Creating Time Manager";
|
||||
// Migration path: nymea < 0.18 doesn't use system time zone but stores its own time zone in the config
|
||||
// For migration, let's set the system's time zone to the config now to upgrade to the system time zone based nymea >= 0.18
|
||||
if (QTimeZone(m_configuration->timeZone()).isValid()) {
|
||||
@ -95,42 +97,42 @@ void NymeaCore::init() {
|
||||
}
|
||||
m_timeManager = new TimeManager(this);
|
||||
|
||||
qCDebug(dcApplication) << "Creating Log Engine";
|
||||
qCDebug(dcCore) << "Creating Log Engine";
|
||||
m_logger = new LogEngine(m_configuration->logDBDriver(), m_configuration->logDBName(), m_configuration->logDBHost(), m_configuration->logDBUser(), m_configuration->logDBPassword(), m_configuration->logDBMaxEntries(), this);
|
||||
|
||||
qCDebug(dcApplication()) << "Creating User Manager";
|
||||
qCDebug(dcCore()) << "Creating User Manager";
|
||||
m_userManager = new UserManager(NymeaSettings::settingsPath() + "/user-db.sqlite", this);
|
||||
|
||||
qCDebug(dcApplication) << "Creating Server Manager";
|
||||
qCDebug(dcCore) << "Creating Server Manager";
|
||||
m_serverManager = new ServerManager(m_platform, m_configuration, this);
|
||||
|
||||
qCDebug(dcApplication) << "Creating Hardware Manager";
|
||||
qCDebug(dcCore) << "Creating Hardware Manager";
|
||||
m_hardwareManager = new HardwareManagerImplementation(m_platform, m_serverManager->mqttBroker(), this);
|
||||
|
||||
qCDebug(dcApplication) << "Creating Thing Manager (locale:" << m_configuration->locale() << ")";
|
||||
qCDebug(dcCore) << "Creating Thing Manager (locale:" << m_configuration->locale() << ")";
|
||||
m_thingManager = new ThingManagerImplementation(m_hardwareManager, m_configuration->locale(), this);
|
||||
|
||||
qCDebug(dcApplication) << "Creating Rule Engine";
|
||||
qCDebug(dcCore) << "Creating Rule Engine";
|
||||
m_ruleEngine = new RuleEngine(this);
|
||||
|
||||
qCDebug(dcApplication()) << "Creating Script Engine";
|
||||
qCDebug(dcCore()) << "Creating Script Engine";
|
||||
m_scriptEngine = new ScriptEngine(m_thingManager, this);
|
||||
m_serverManager->jsonServer()->registerHandler(new ScriptsHandler(m_scriptEngine, m_scriptEngine));
|
||||
|
||||
qCDebug(dcApplication()) << "Creating Tags Storage";
|
||||
qCDebug(dcCore()) << "Creating Tags Storage";
|
||||
m_tagsStorage = new TagsStorage(m_thingManager, m_ruleEngine, this);
|
||||
|
||||
qCDebug(dcApplication) << "Creating Network Manager";
|
||||
qCDebug(dcCore) << "Creating Network Manager";
|
||||
m_networkManager = new NetworkManager(this);
|
||||
m_networkManager->start();
|
||||
|
||||
qCDebug(dcApplication) << "Creating Debug Server Handler";
|
||||
qCDebug(dcCore) << "Creating Debug Server Handler";
|
||||
m_debugServerHandler = new DebugServerHandler(this);
|
||||
|
||||
qCDebug(dcApplication) << "Creating Cloud Manager";
|
||||
qCDebug(dcCore) << "Creating Cloud Manager";
|
||||
m_cloudManager = new CloudManager(m_configuration, m_networkManager, this);
|
||||
|
||||
qCDebug(dcApplication()) << "Loading experiences";
|
||||
qCDebug(dcCore()) << "Loading experiences";
|
||||
m_experienceManager = new ExperienceManager(m_thingManager, m_serverManager->jsonServer(), this);
|
||||
|
||||
|
||||
@ -164,7 +166,7 @@ void NymeaCore::init() {
|
||||
/*! Destructor of the \l{NymeaCore}. */
|
||||
NymeaCore::~NymeaCore()
|
||||
{
|
||||
qCDebug(dcApplication()) << "Shutting down NymeaCore";
|
||||
qCDebug(dcCore()) << "Shutting down NymeaCore";
|
||||
m_logger->logSystemEvent(m_timeManager->currentDateTime(), false);
|
||||
|
||||
// Disconnect all signals/slots, we're going down now
|
||||
@ -173,27 +175,27 @@ NymeaCore::~NymeaCore()
|
||||
m_ruleEngine->disconnect(this);
|
||||
|
||||
// At very first, cut off the outside world
|
||||
qCDebug(dcApplication) << "Shutting down \"Server Manager\"";
|
||||
qCDebug(dcCore) << "Shutting down \"Server Manager\"";
|
||||
delete m_serverManager;
|
||||
qCDebug(dcApplication) << "Shutting down \"CloudManager\"";
|
||||
qCDebug(dcCore) << "Shutting down \"CloudManager\"";
|
||||
delete m_cloudManager;
|
||||
|
||||
// Then stop magic from happening
|
||||
qCDebug(dcApplication) << "Shutting down \"Rule Engine\"";
|
||||
qCDebug(dcCore) << "Shutting down \"Rule Engine\"";
|
||||
delete m_ruleEngine;
|
||||
|
||||
// Next, ThingManager, so plugins don't access any resources any more.
|
||||
qCDebug(dcApplication) << "Shutting down \"Thing Manager\"";
|
||||
qCDebug(dcCore) << "Shutting down \"Thing Manager\"";
|
||||
delete m_thingManager;
|
||||
|
||||
// Now go ahead and clean up stuff.
|
||||
qCDebug(dcApplication) << "Shutting down \"Log Engine\"";
|
||||
qCDebug(dcCore) << "Shutting down \"Log Engine\"";
|
||||
delete m_logger;
|
||||
|
||||
qCDebug(dcApplication()) << "Shutting down \"Hardware Manager\"";
|
||||
qCDebug(dcCore()) << "Shutting down \"Hardware Manager\"";
|
||||
delete m_hardwareManager;
|
||||
|
||||
qCDebug(dcApplication) << "Done shutting down NymeaCore";
|
||||
qCDebug(dcCore) << "Done shutting down NymeaCore";
|
||||
}
|
||||
|
||||
void NymeaCore::destroy()
|
||||
@ -567,7 +569,7 @@ ServerManager *NymeaCore::serverManager() const
|
||||
|
||||
QStringList NymeaCore::getAvailableLanguages()
|
||||
{
|
||||
qCDebug(dcApplication()) << "Loading translations from" << NymeaSettings::translationsPath();
|
||||
qCDebug(dcCore()) << "Loading translations from" << NymeaSettings::translationsPath();
|
||||
|
||||
QStringList searchPaths;
|
||||
searchPaths << QCoreApplication::applicationDirPath() + "/../translations";
|
||||
@ -599,52 +601,7 @@ QStringList NymeaCore::getAvailableLanguages()
|
||||
|
||||
QStringList NymeaCore::loggingFilters()
|
||||
{
|
||||
QStringList loggingFilters = {
|
||||
"Warnings",
|
||||
"Application",
|
||||
"System",
|
||||
"Platform",
|
||||
"PlatformUpdate",
|
||||
"PlatformZeroConf",
|
||||
"Experiences",
|
||||
"Thing",
|
||||
"ThingManager",
|
||||
"RuleEngine",
|
||||
"RuleEngineDebug",
|
||||
"ScriptEngine",
|
||||
"Hardware",
|
||||
"Bluetooth",
|
||||
"LogEngine",
|
||||
"ServerManager",
|
||||
"TcpServer",
|
||||
"TcpServerTraffic",
|
||||
"WebServer",
|
||||
"WebServerTraffic",
|
||||
"DebugServer",
|
||||
"WebSocketServer",
|
||||
"WebSocketServerTraffic",
|
||||
"JsonRpc",
|
||||
"JsonRpcTraffic",
|
||||
"Rest",
|
||||
"OAuth2",
|
||||
"TimeManager",
|
||||
"Coap",
|
||||
"Avahi",
|
||||
"AvahiDebug",
|
||||
"UPnP",
|
||||
"Cloud",
|
||||
"CloudTraffic",
|
||||
"NetworkManager",
|
||||
"UserManager",
|
||||
"AWS",
|
||||
"AWSTraffic",
|
||||
"BluetoothServer",
|
||||
"BluetoothServerTraffic",
|
||||
"Mqtt",
|
||||
"Translations"
|
||||
};
|
||||
|
||||
return loggingFilters;
|
||||
return s_nymeaLoggingCategories;
|
||||
}
|
||||
|
||||
QStringList NymeaCore::loggingFiltersPlugins()
|
||||
@ -860,22 +817,22 @@ void NymeaCore::thingManagerLoaded()
|
||||
emit initialized();
|
||||
|
||||
// Do some houskeeping...
|
||||
qCDebug(dcApplication()) << "Starting housekeeping...";
|
||||
qCDebug(dcCore()) << "Starting housekeeping...";
|
||||
QDateTime startTime = QDateTime::currentDateTime();
|
||||
ThingsFetchJob *job = m_logger->fetchThings();
|
||||
connect(job, &ThingsFetchJob::finished, m_thingManager, [this, job, startTime](){
|
||||
foreach (const ThingId &thingId, job->results()) {
|
||||
if (!m_thingManager->findConfiguredThing(thingId)) {
|
||||
qCDebug(dcApplication()) << "Cleaning stale thing entries from log DB for thing id" << thingId;
|
||||
qCDebug(dcCore()) << "Cleaning stale thing entries from log DB for thing id" << thingId;
|
||||
m_logger->removeThingLogs(thingId);
|
||||
}
|
||||
}
|
||||
qCDebug(dcApplication()) << "Housekeeping done in" << startTime.msecsTo(QDateTime::currentDateTime()) << "ms.";
|
||||
qCDebug(dcCore()) << "Housekeeping done in" << startTime.msecsTo(QDateTime::currentDateTime()) << "ms.";
|
||||
});
|
||||
|
||||
foreach (const ThingId &thingId, m_ruleEngine->thingsInRules()) {
|
||||
if (!m_thingManager->findConfiguredThing(thingId)) {
|
||||
qCDebug(dcApplication()) << "Cleaning stale rule entries for thing id" << thingId;
|
||||
qCDebug(dcCore()) << "Cleaning stale rule entries for thing id" << thingId;
|
||||
foreach (const RuleId &ruleId, m_ruleEngine->findRules(thingId)) {
|
||||
m_ruleEngine->removeThingFromRule(ruleId, thingId);
|
||||
}
|
||||
|
||||
@ -33,46 +33,48 @@
|
||||
#include <QDir>
|
||||
#include <QDateTime>
|
||||
|
||||
Q_LOGGING_CATEGORY(dcApplication, "Application")
|
||||
Q_LOGGING_CATEGORY(dcPluginMetadata, "PluginMetadata")
|
||||
Q_LOGGING_CATEGORY(dcThing, "Thing")
|
||||
Q_LOGGING_CATEGORY(dcThingManager, "ThingManager")
|
||||
Q_LOGGING_CATEGORY(dcSystem, "System")
|
||||
Q_LOGGING_CATEGORY(dcPlatform, "Platform")
|
||||
Q_LOGGING_CATEGORY(dcPlatformUpdate, "PlatformUpdate")
|
||||
Q_LOGGING_CATEGORY(dcPlatformZeroConf, "PlatformZeroConf")
|
||||
Q_LOGGING_CATEGORY(dcExperiences, "Experiences")
|
||||
Q_LOGGING_CATEGORY(dcTimeManager, "TimeManager")
|
||||
Q_LOGGING_CATEGORY(dcRuleEngine, "RuleEngine")
|
||||
Q_LOGGING_CATEGORY(dcRuleEngineDebug, "RuleEngineDebug")
|
||||
Q_LOGGING_CATEGORY(dcScriptEngine, "ScriptEngine")
|
||||
Q_LOGGING_CATEGORY(dcHardware, "Hardware")
|
||||
Q_LOGGING_CATEGORY(dcLogEngine, "LogEngine")
|
||||
Q_LOGGING_CATEGORY(dcServerManager, "ServerManager")
|
||||
Q_LOGGING_CATEGORY(dcTcpServer, "TcpServer")
|
||||
Q_LOGGING_CATEGORY(dcTcpServerTraffic, "TcpServerTraffic")
|
||||
Q_LOGGING_CATEGORY(dcWebServer, "WebServer")
|
||||
Q_LOGGING_CATEGORY(dcWebServerTraffic, "WebServerTraffic")
|
||||
Q_LOGGING_CATEGORY(dcDebugServer, "DebugServer")
|
||||
Q_LOGGING_CATEGORY(dcWebSocketServer, "WebSocketServer")
|
||||
Q_LOGGING_CATEGORY(dcWebSocketServerTraffic, "WebSocketServerTraffic")
|
||||
Q_LOGGING_CATEGORY(dcJsonRpc, "JsonRpc")
|
||||
Q_LOGGING_CATEGORY(dcJsonRpcTraffic, "JsonRpcTraffic")
|
||||
Q_LOGGING_CATEGORY(dcRest, "Rest")
|
||||
Q_LOGGING_CATEGORY(dcOAuth2, "OAuth2")
|
||||
Q_LOGGING_CATEGORY(dcUpnp, "UPnP")
|
||||
Q_LOGGING_CATEGORY(dcBluetooth, "Bluetooth")
|
||||
Q_LOGGING_CATEGORY(dcCloud, "Cloud")
|
||||
Q_LOGGING_CATEGORY(dcCloudTraffic, "CloudTraffic")
|
||||
Q_LOGGING_CATEGORY(dcNetworkManager, "NetworkManager")
|
||||
Q_LOGGING_CATEGORY(dcUserManager, "UserManager")
|
||||
Q_LOGGING_CATEGORY(dcAWS, "AWS")
|
||||
Q_LOGGING_CATEGORY(dcAWSTraffic, "AWSTraffic")
|
||||
Q_LOGGING_CATEGORY(dcBluetoothServer, "BluetoothServer")
|
||||
Q_LOGGING_CATEGORY(dcBluetoothServerTraffic, "BluetoothServerTraffic")
|
||||
Q_LOGGING_CATEGORY(dcMqtt, "Mqtt")
|
||||
Q_LOGGING_CATEGORY(dcTranslations, "Translations")
|
||||
Q_LOGGING_CATEGORY(dcI2C, "I2C")
|
||||
QStringList s_nymeaLoggingCategories;
|
||||
|
||||
// FIXME: Those should eventually disappear from here
|
||||
NYMEA_LOGGING_CATEGORY(dcPluginMetadata, "PluginMetadata")
|
||||
NYMEA_LOGGING_CATEGORY(dcThing, "Thing")
|
||||
NYMEA_LOGGING_CATEGORY(dcThingManager, "ThingManager")
|
||||
NYMEA_LOGGING_CATEGORY(dcSystem, "System")
|
||||
NYMEA_LOGGING_CATEGORY(dcPlatform, "Platform")
|
||||
NYMEA_LOGGING_CATEGORY(dcPlatformUpdate, "PlatformUpdate")
|
||||
NYMEA_LOGGING_CATEGORY(dcPlatformZeroConf, "PlatformZeroConf")
|
||||
NYMEA_LOGGING_CATEGORY(dcExperiences, "Experiences")
|
||||
NYMEA_LOGGING_CATEGORY(dcTimeManager, "TimeManager")
|
||||
NYMEA_LOGGING_CATEGORY(dcRuleEngine, "RuleEngine")
|
||||
NYMEA_LOGGING_CATEGORY(dcRuleEngineDebug, "RuleEngineDebug")
|
||||
NYMEA_LOGGING_CATEGORY(dcScriptEngine, "ScriptEngine")
|
||||
NYMEA_LOGGING_CATEGORY(dcHardware, "Hardware")
|
||||
NYMEA_LOGGING_CATEGORY(dcLogEngine, "LogEngine")
|
||||
NYMEA_LOGGING_CATEGORY(dcServerManager, "ServerManager")
|
||||
NYMEA_LOGGING_CATEGORY(dcTcpServer, "TcpServer")
|
||||
NYMEA_LOGGING_CATEGORY(dcTcpServerTraffic, "TcpServerTraffic")
|
||||
NYMEA_LOGGING_CATEGORY(dcWebServer, "WebServer")
|
||||
NYMEA_LOGGING_CATEGORY(dcWebServerTraffic, "WebServerTraffic")
|
||||
NYMEA_LOGGING_CATEGORY(dcDebugServer, "DebugServer")
|
||||
NYMEA_LOGGING_CATEGORY(dcWebSocketServer, "WebSocketServer")
|
||||
NYMEA_LOGGING_CATEGORY(dcWebSocketServerTraffic, "WebSocketServerTraffic")
|
||||
NYMEA_LOGGING_CATEGORY(dcJsonRpc, "JsonRpc")
|
||||
NYMEA_LOGGING_CATEGORY(dcJsonRpcTraffic, "JsonRpcTraffic")
|
||||
NYMEA_LOGGING_CATEGORY(dcRest, "Rest")
|
||||
NYMEA_LOGGING_CATEGORY(dcOAuth2, "OAuth2")
|
||||
NYMEA_LOGGING_CATEGORY(dcUpnp, "UPnP")
|
||||
NYMEA_LOGGING_CATEGORY(dcBluetooth, "Bluetooth")
|
||||
NYMEA_LOGGING_CATEGORY(dcCloud, "Cloud")
|
||||
NYMEA_LOGGING_CATEGORY(dcCloudTraffic, "CloudTraffic")
|
||||
NYMEA_LOGGING_CATEGORY(dcNetworkManager, "NetworkManager")
|
||||
NYMEA_LOGGING_CATEGORY(dcUserManager, "UserManager")
|
||||
NYMEA_LOGGING_CATEGORY(dcAWS, "AWS")
|
||||
NYMEA_LOGGING_CATEGORY(dcAWSTraffic, "AWSTraffic")
|
||||
NYMEA_LOGGING_CATEGORY(dcBluetoothServer, "BluetoothServer")
|
||||
NYMEA_LOGGING_CATEGORY(dcBluetoothServerTraffic, "BluetoothServerTraffic")
|
||||
NYMEA_LOGGING_CATEGORY(dcMqtt, "Mqtt")
|
||||
NYMEA_LOGGING_CATEGORY(dcTranslations, "Translations")
|
||||
NYMEA_LOGGING_CATEGORY(dcI2C, "I2C")
|
||||
|
||||
|
||||
static QFile s_logFile;
|
||||
|
||||
@ -34,8 +34,21 @@
|
||||
#include <QLoggingCategory>
|
||||
#include <QDebug>
|
||||
|
||||
// Core / libnymea
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcApplication)
|
||||
extern QStringList s_nymeaLoggingCategories;
|
||||
|
||||
|
||||
#define NYMEA_LOGGING_CATEGORY(name, string) \
|
||||
class NymeaLoggingCategory##name: public QLoggingCategory { \
|
||||
public: \
|
||||
NymeaLoggingCategory##name(): QLoggingCategory(string) { s_nymeaLoggingCategories.append(string); } \
|
||||
}; \
|
||||
static NymeaLoggingCategory##name s_##name; \
|
||||
const QLoggingCategory &name() \
|
||||
{ \
|
||||
return s_##name; \
|
||||
} \
|
||||
|
||||
// FIXME: Those should eventually disappear from here
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcPluginMetadata)
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcThing)
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcThingManager)
|
||||
@ -77,6 +90,7 @@ Q_DECLARE_LOGGING_CATEGORY(dcTranslations)
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcCoap)
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcI2C)
|
||||
|
||||
|
||||
/*
|
||||
Installs a nymea log message handler in the system.
|
||||
This is different to the qLogMessageHandler which works like a chain.
|
||||
|
||||
@ -31,6 +31,8 @@
|
||||
#include "nymeadbusservice.h"
|
||||
#include "loggingcategories.h"
|
||||
|
||||
NYMEA_LOGGING_CATEGORY(dcDBus, "DBus")
|
||||
|
||||
QDBusConnection::BusType NymeaDBusService::s_busType = QDBusConnection::SystemBus;
|
||||
|
||||
NymeaDBusService::NymeaDBusService(const QString &objectPath, QObject *parent):
|
||||
@ -39,7 +41,7 @@ NymeaDBusService::NymeaDBusService(const QString &objectPath, QObject *parent):
|
||||
{
|
||||
bool status = m_connection.registerService("io.guh.nymead");
|
||||
if (!status) {
|
||||
qCWarning(dcApplication()) << "Failed to register D-Bus service.";
|
||||
qCWarning(dcDBus()) << "Failed to register D-Bus service.";
|
||||
return;
|
||||
}
|
||||
QString finalObjectPath;
|
||||
@ -49,7 +51,7 @@ NymeaDBusService::NymeaDBusService(const QString &objectPath, QObject *parent):
|
||||
}
|
||||
status = m_connection.registerObject(finalObjectPath, "io.guh.nymead", parent, QDBusConnection::ExportScriptableSlots);
|
||||
if (!status) {
|
||||
qCWarning(dcApplication()) << "Failed to register D-Bus object:" << finalObjectPath;
|
||||
qCWarning(dcDBus()) << "Failed to register D-Bus object:" << finalObjectPath;
|
||||
return;
|
||||
}
|
||||
m_isValid = true;
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
#include "loggingcategories.h"
|
||||
#include "version.h"
|
||||
|
||||
NYMEA_LOGGING_CATEGORY(dcApplication, "Application")
|
||||
|
||||
using namespace nymeaserver;
|
||||
|
||||
|
||||
@ -56,6 +56,8 @@
|
||||
#include <unistd.h>
|
||||
#include <cxxabi.h>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcApplication)
|
||||
|
||||
namespace nymeaserver {
|
||||
|
||||
static bool s_aboutToShutdown = false;
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
#include "loggingcategories.h"
|
||||
#include "version.h"
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(dcApplication)
|
||||
|
||||
namespace nymeaserver {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user