Add support for printing more information in diagnosis log

Also yacreaderlibraryserver can now print this with the --system-info option

This will help when giving support to users.
This commit is contained in:
Luis Ángel San Martín
2024-09-05 17:48:48 +02:00
parent a3f3149764
commit 1c48f05398
7 changed files with 90 additions and 49 deletions

View File

@ -10,6 +10,7 @@
#include "yacreader_global.h"
#include "yacreader_libraries.h"
#include "yacreader_local_server.h"
#include "global_info_provider.h"
#include "libraries_update_coordinator.h"
@ -88,6 +89,7 @@ int main(int argc, char **argv)
parser.addPositionalArgument("command", "The command to execute. [start, create-library, update-library, add-library, remove-library, list-libraries, set-port, rescan-xml-info]");
parser.addOption({ "loglevel", "Set log level. Valid values: trace, info, debug, warn, error.", "loglevel", "info" });
parser.addOption({ "port", "Set server port (temporary). Valid values: 1-65535", "port" });
parser.addOption({ "system-info", "Prints detailed information about the system environment, including OS version, hardware specifications, and available resources." });
parser.parse(app.arguments());
const QStringList args = parser.positionalArguments();
@ -100,6 +102,15 @@ int main(int argc, char **argv)
return 0;
}
if (parser.isSet("system-info")) {
auto globalInfo = YACReader::getGlobalInfo();
for (const auto &line : globalInfo.split("\n")) {
qout << line << Qt::endl;
}
return 0;
}
QSettings *settings = new QSettings(settingsPath, QSettings::IniFormat);
settings->beginGroup("libraryConfig");
@ -444,8 +455,10 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
void logSystemAndConfig()
{
QLOG_INFO() << "---------- System & configuration ----------";
QLOG_INFO() << "OS:" << QSysInfo::prettyProductName() << "Version: " << QSysInfo::productVersion();
QLOG_INFO() << "Kernel:" << QSysInfo::kernelType() << QSysInfo::kernelVersion() << "Architecture:" << QSysInfo::currentCpuArchitecture();
auto globalInfo = YACReader::getGlobalInfo();
for (const auto &line : globalInfo.split("\n")) {
QLOG_INFO() << line;
}
QLOG_INFO() << "Libraries: " << DBHelper::getLibraries().getLibraries();
QLOG_INFO() << "--------------------------------------------";
}