From 1c48f053981e85c5166eec509dc8c8616f1bcca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 5 Sep 2024 17:48:48 +0200 Subject: [PATCH] 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. --- YACReader/YACReader.pro | 6 ++- YACReaderLibrary/YACReaderLibrary.pro | 6 ++- .../YACReaderLibraryServer.pro | 2 + YACReaderLibraryServer/main.cpp | 17 ++++++- common/global_info_provider.cpp | 51 +++++++++++++++++++ common/global_info_provider.h | 12 +++++ custom_widgets/help_about_dialog.cpp | 45 +--------------- 7 files changed, 90 insertions(+), 49 deletions(-) create mode 100644 common/global_info_provider.cpp create mode 100644 common/global_info_provider.h diff --git a/YACReader/YACReader.pro b/YACReader/YACReader.pro index 08502677..b57683da 100644 --- a/YACReader/YACReader.pro +++ b/YACReader/YACReader.pro @@ -106,7 +106,8 @@ HEADERS += ../common/comic.h \ ../common/exit_check.h \ ../common/scroll_management.h \ ../common/opengl_checker.h \ - ../common/pdf_comic.h + ../common/pdf_comic.h \ + ../common/global_info_provider.h \ !CONFIG(no_opengl) { HEADERS += ../common/gl/yacreader_flow_gl.h \ @@ -143,7 +144,8 @@ SOURCES += ../common/comic.cpp \ ../common/yacreader_global_gui.cpp \ ../common/exit_check.cpp \ ../common/scroll_management.cpp \ - ../common/opengl_checker.cpp + ../common/opengl_checker.cpp \ + ../common/global_info_provider.cpp \ !CONFIG(no_opengl) { SOURCES += ../common/gl/yacreader_flow_gl.cpp \ diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index ddbc6575..d4ebf6d8 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -154,7 +154,8 @@ HEADERS += comic_flow.h \ db/reading_list.h \ db/query_parser.h \ current_comic_view_helper.h \ - ip_config_helper.h + ip_config_helper.h \ + ../common/global_info_provider.h \ !CONFIG(no_opengl) { HEADERS += ../common/gl/yacreader_flow_gl.h @@ -240,7 +241,8 @@ SOURCES += comic_flow.cpp \ db/reading_list.cpp \ current_comic_view_helper.cpp \ db/query_parser.cpp \ - ip_config_helper.cpp + ip_config_helper.cpp \ + ../common/global_info_provider.cpp \ !CONFIG(no_opengl) { SOURCES += ../common/gl/yacreader_flow_gl.cpp diff --git a/YACReaderLibraryServer/YACReaderLibraryServer.pro b/YACReaderLibraryServer/YACReaderLibraryServer.pro index 7c892f61..333876a0 100644 --- a/YACReaderLibraryServer/YACReaderLibraryServer.pro +++ b/YACReaderLibraryServer/YACReaderLibraryServer.pro @@ -69,6 +69,7 @@ HEADERS += ../YACReaderLibrary/library_creator.h \ ../YACReaderLibrary/db/query_parser.h \ ../YACReaderLibrary/db/search_query.h \ ../YACReaderLibrary/libraries_update_coordinator.h \ + ../common/global_info_provider.h \ SOURCES += ../YACReaderLibrary/library_creator.cpp \ @@ -100,6 +101,7 @@ SOURCES += ../YACReaderLibrary/library_creator.cpp \ ../YACReaderLibrary/db/query_parser.cpp \ ../YACReaderLibrary/db/search_query.cpp \ ../YACReaderLibrary/libraries_update_coordinator.cpp \ + ../common/global_info_provider.cpp \ include(../YACReaderLibrary/server/server.pri) diff --git a/YACReaderLibraryServer/main.cpp b/YACReaderLibraryServer/main.cpp index 46363826..dd087cf8 100644 --- a/YACReaderLibraryServer/main.cpp +++ b/YACReaderLibraryServer/main.cpp @@ -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() << "--------------------------------------------"; } diff --git a/common/global_info_provider.cpp b/common/global_info_provider.cpp new file mode 100644 index 00000000..097a52ba --- /dev/null +++ b/common/global_info_provider.cpp @@ -0,0 +1,51 @@ +#include "global_info_provider.h" + +#include +#include +#include + +#ifdef YACREADER_LIBRARY +#include +#endif + +QString YACReader::getGlobalInfo() +{ + QString text; + + text.append("SYSTEM INFORMATION\n"); + text.append(QString("Qt version: %1\n").arg(qVersion())); + text.append(QString("Build ABI: %1\n").arg(QSysInfo::buildAbi())); + text.append(QString("build CPU architecture: %1\n").arg(QSysInfo::buildCpuArchitecture())); + text.append(QString("CPU architecture: %1\n").arg(QSysInfo::currentCpuArchitecture())); + text.append(QString("Kernel type: %1\n").arg(QSysInfo::kernelType())); + text.append(QString("Kernel version: %1\n").arg(QSysInfo::kernelVersion())); + text.append(QString("Product info: %1\n").arg(QSysInfo::prettyProductName())); + + text.append("\nAPP INFORMATION\n"); + text.append(QString("Image formats supported: %1\n").arg(QImageReader::supportedImageFormats().join(", "))); + // append if sqlite driver is available +#ifdef YACREADER_LIBRARY + text.append(QString("SQLite driver available: %1\n").arg(QSqlDatabase::isDriverAvailable("QSQLITE") ? "yes" : "no")); +#endif + +#ifdef use_unarr + text.append("Compression backend: unarr (no RAR5 support)\n"); +#elif defined use_libarchive + text.append("Compression backend: libarchive\n"); +#else + text.append("Compression backend: 7zip\n"); +#endif + +// print pdf backend used, poppler, pdfkit, pdfium +#ifdef NO_PDF + text.append("PDF support: None\n"); +#elif defined USE_PDFKIT + text.append("PDF support: PDFKit\n"); +#elif defined USE_PDFIUM + text.append("PDF support: PDFium\n"); +#else + text.append("PDF support: Poppler\n"); +#endif + + return text; +} diff --git a/common/global_info_provider.h b/common/global_info_provider.h new file mode 100644 index 00000000..75b3c172 --- /dev/null +++ b/common/global_info_provider.h @@ -0,0 +1,12 @@ +#ifndef GLOBAL_INFO_PROVIDER_H +#define GLOBAL_INFO_PROVIDER_H + +#include + +namespace YACReader { + +QString getGlobalInfo(); + +} + +#endif // GLOBAL_INFO_PROVIDER_H diff --git a/custom_widgets/help_about_dialog.cpp b/custom_widgets/help_about_dialog.cpp index 818adc80..2ba8bf6a 100644 --- a/custom_widgets/help_about_dialog.cpp +++ b/custom_widgets/help_about_dialog.cpp @@ -1,6 +1,7 @@ #include "help_about_dialog.h" #include "opengl_checker.h" +#include "global_info_provider.h" #include #include @@ -97,54 +98,12 @@ QString HelpAboutDialog::fileToString(const QString &path) void HelpAboutDialog::loadSystemInfo() { - QString text; - - text.append("SYSTEM INFORMATION\n"); - text.append(QString("Qt version: %1\n").arg(qVersion())); - text.append(QString("Build ABI: %1\n").arg(QSysInfo::buildAbi())); - text.append(QString("build CPU architecture: %1\n").arg(QSysInfo::buildCpuArchitecture())); - text.append(QString("CPU architecture: %1\n").arg(QSysInfo::currentCpuArchitecture())); - text.append(QString("Kernel type: %1\n").arg(QSysInfo::kernelType())); - text.append(QString("Kernel version: %1\n").arg(QSysInfo::kernelVersion())); - text.append(QString("Product info: %1\n").arg(QSysInfo::prettyProductName())); - - // QProcess systemInfoProcess; - // QString tempOutput; - - // if (QSysInfo::kernelType() == "winnt") { - // QString cpuname = "wmic cpu get name"; - // systemInfoProcess.start("cmd", QList() << "/C" << cpuname); - // systemInfoProcess.waitForFinished(); - // tempOutput = QString(systemInfoProcess.readAllStandardOutput()).replace("\n", " "); - // text.append(QString("CPU: %1\n").arg(tempOutput)); - // } - - // if (QSysInfo::kernelType() == "linux") { - // QString cpuname = "cat /proc/cpuinfo | grep 'model name' | uniq"; - // systemInfoProcess.start("bash", QList() << "-c" << cpuname); - // systemInfoProcess.waitForFinished(); - // tempOutput = systemInfoProcess.readAllStandardOutput(); - // text.append(QString("CPU: %1\n").arg(tempOutput)); - // } + auto text = YACReader::getGlobalInfo(); auto openGLChecker = OpenGLChecker(); text.append("\nGRAPHIC INFORMATION\n"); text.append(QString("Screen pixel ratio: %1\n").arg(devicePixelRatioF())); text.append(QString("OpenGL version: %1\n").arg(openGLChecker.textVersionDescription())); - // if (QSysInfo::kernelType() == "winnt") { - // QString gpu = "wmic PATH Win32_videocontroller get VideoProcessor"; - // systemInfoProcess.start("cmd", QList() << "/C" << gpu); - // systemInfoProcess.waitForFinished(); - // tempOutput = systemInfoProcess.readAllStandardOutput(); - // text.append(QString("GPU: %1\n").arg(tempOutput)); - - // QString gpuram = "wmic PATH Win32_VideoController get AdapterRAM"; - // systemInfoProcess.start("cmd", QList() << "/C" << gpuram); - // systemInfoProcess.waitForFinished(); - // tempOutput = systemInfoProcess.readAllStandardOutput(); - // text.append(QString("GPU RAM: %1\n").arg(tempOutput)); - // } - systemInfoText->setText(text); }