Add dynamic logging filter elements for core and plugins in the livelog view

This commit is contained in:
Simon Stürz 2019-10-07 12:04:52 +02:00
parent dc6c4b88df
commit b4f32c073a
5 changed files with 117 additions and 82 deletions

View File

@ -263,7 +263,7 @@ button::-moz-focus-inner { border: 0; }
.categories-area {
display: -webkit-flex;
display: flex;
flex-flow: row nowrap;
flex-flow: row wrap;
}
.debug-category {
@ -335,11 +335,11 @@ button::-moz-focus-inner { border: 0; }
}
input:checked + .slider {
background-color: #2196F3;
background-color: #57baae;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
box-shadow: 0 0 1px #57baae;
}
input:checked + .slider:before {

View File

@ -1720,42 +1720,62 @@ QByteArray DebugServerHandler::createDebugXmlDocument()
writer.writeCharacters("");
writer.writeEndElement(); // textarea
writer.writeEmptyElement("hr");
//: The network section of the debug interface
writer.writeTextElement("h2", tr("Logging filters"));
writer.writeEmptyElement("hr");
writer.writeStartElement("div");
writer.writeAttribute("class", "categories-area");
// Application debug category
writer.writeStartElement("div");
writer.writeAttribute("class", "debug-category");
writer.writeTextElement("p", "Application");
writer.writeStartElement("label");
writer.writeAttribute("class", "switch");
writer.writeStartElement("input");
writer.writeAttribute("type", "checkbox");
writer.writeEndElement(); // input
writer.writeStartElement("span");
writer.writeAttribute("class", "slider round");
writer.writeCharacters("");
writer.writeEndElement(); // span
writer.writeEndElement(); // label
writer.writeEndElement(); // div debug-category
QStringList loggingCategories = NymeaCore::loggingFilters();
loggingCategories.sort();
foreach (const QString &loggingCategory, loggingCategories) {
writer.writeStartElement("div");
writer.writeAttribute("class", "debug-category");
writer.writeTextElement("p", loggingCategory);
writer.writeStartElement("label");
writer.writeAttribute("class", "switch");
writer.writeStartElement("input");
writer.writeAttribute("type", "checkbox");
writer.writeEndElement(); // input
writer.writeStartElement("span");
writer.writeAttribute("class", "slider round");
writer.writeCharacters("");
writer.writeEndElement(); // span
writer.writeEndElement(); // label
writer.writeEndElement(); // div debug-category
}
writer.writeEndElement(); // div categories-area
writer.writeEmptyElement("hr");
//: The network section of the debug interface
writer.writeTextElement("h2", tr("Logging filters plugins"));
writer.writeEmptyElement("hr");
writer.writeStartElement("div");
writer.writeAttribute("class", "debug-category");
writer.writeTextElement("p", "DeviceManager");
writer.writeStartElement("label");
writer.writeAttribute("class", "switch");
writer.writeStartElement("input");
writer.writeAttribute("type", "checkbox");
writer.writeEndElement(); // input
writer.writeStartElement("span");
writer.writeAttribute("class", "slider round");
writer.writeCharacters("");
writer.writeEndElement(); // span
writer.writeEndElement(); // label
writer.writeEndElement(); // div debug-category
writer.writeAttribute("class", "categories-area");
// Provide options for debug categories
QStringList loggingCategoriesPlugins = NymeaCore::loggingFiltersPlugins();
loggingCategoriesPlugins.sort();
foreach (const QString &loggingCategory, loggingCategoriesPlugins) {
writer.writeStartElement("div");
writer.writeAttribute("class", "debug-category");
writer.writeTextElement("p", loggingCategory);
writer.writeStartElement("label");
writer.writeAttribute("class", "switch");
writer.writeStartElement("input");
writer.writeAttribute("type", "checkbox");
writer.writeEndElement(); // input
writer.writeStartElement("span");
writer.writeAttribute("class", "slider round");
writer.writeCharacters("");
writer.writeEndElement(); // span
writer.writeEndElement(); // label
writer.writeEndElement(); // div debug-category
}
writer.writeEndElement(); // div categories-area

View File

@ -690,6 +690,65 @@ QStringList NymeaCore::getAvailableLanguages()
return availableLanguages;
}
/*! Returns the list of logging categories from the core and the libnymea. */
QStringList NymeaCore::loggingFilters()
{
QStringList loggingFilters = {
"Warnings",
"Application",
"System",
"Platform",
"PlatformUpdate",
"PlatformZeroConf",
"Device",
"DeviceManager",
"RuleEngine",
"RuleEngineDebug",
"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;
}
QStringList NymeaCore::loggingFiltersPlugins()
{
QStringList loggingFiltersPlugins;
foreach (const QJsonObject &pluginMetadata, DeviceManagerImplementation::pluginsMetadata()) {
QString pluginName = pluginMetadata.value("name").toString();
loggingFiltersPlugins << pluginName.left(1).toUpper() + pluginName.mid(1);
}
return loggingFiltersPlugins;
}
/*! Returns a pointer to the \l{BluetoothServer} instance owned by NymeaCore. */
BluetoothServer *NymeaCore::bluetoothServer() const
{

View File

@ -96,6 +96,8 @@ public:
Platform *platform() const;
static QStringList getAvailableLanguages();
static QStringList loggingFilters();
static QStringList loggingFiltersPlugins();
signals:
void initialized();

View File

@ -97,55 +97,9 @@ int main(int argc, char *argv[])
application.setApplicationName("nymead");
application.setApplicationVersion(NYMEA_VERSION_STRING);
// logging filers for core and libnymea
QStringList loggingFilters = {
"Warnings",
"Application",
"System",
"Platform",
"PlatformUpdate",
"PlatformZeroConf",
"Device",
"DeviceManager",
"RuleEngine",
"RuleEngineDebug",
"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"
};
QStringList loggingFiltersPlugins;
foreach (const QJsonObject &pluginMetadata, DeviceManagerImplementation::pluginsMetadata()) {
QString pluginName = pluginMetadata.value("name").toString();
loggingFiltersPlugins << pluginName.left(1).toUpper() + pluginName.mid(1);
}
// Logging filers for core + libnymea and plugins
QStringList loggingFilters = NymeaCore::loggingFilters();
QStringList loggingFiltersPlugins = NymeaCore::loggingFiltersPlugins();
// Translator for the server application
QTranslator translator;