From 702619a8e01e5adebcc5cf0508cc485c3066c9db Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 30 Dec 2023 08:50:10 -0500 Subject: [PATCH] Support dragonx debug log and custom number of lines --- src/mainwindow.cpp | 24 +++++++++++++++--------- src/mainwindow.h | 2 +- src/mainwindow.ui | 19 ++++++++++++++++++- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d0ee83b..f9e8afb 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1986,16 +1986,17 @@ void MainWindow::setupMiningTab() { } } -QString MainWindow::readDebugLines() { +QString MainWindow::readDebugLines(uint32_t lines) { + QString coin = isdragonx ? "DRAGONX" : "HUSH3"; #ifdef Q_OS_LINUX - QFile file(QDir::homePath() + "/.hush/HUSH3/debug.log"); + QFile file(QDir::homePath() + "/.hush/" + coin + "/debug.log"); #elif defined(Q_OS_DARWIN) - QFile file(QDir::homePath() + "/Library/Application Support/Hush/HUSH3/debug.log"); + QFile file(QDir::homePath() + "/Library/Application Support/Hush/" + coin + "/debug.log"); #elif defined(Q_OS_WIN64) - QFile file(QDir::homePath() + "/AppData/Roaming/Hush/HUSH3/debug.log"); + QFile file(QDir::homePath() + "/AppData/Roaming/Hush/" + coin + "/debug.log"); #else // Bless Your Heart, You Like Danger! - QFile file("~/.hush/HUSH3/debug.log"); + QFile file(QDir::homePath() + "/.hush/" + coin + "/debug.log"); #endif // Q_OS_LINUX if(file.exists()) { DEBUG(": Found debug.log at " << file); @@ -2008,9 +2009,12 @@ QString MainWindow::readDebugLines() { { qint64 fileSize = file.size(); DEBUG("debug.log size=" << fileSize); + if(fileSize < 2) { + DEBUG("debug.log is too small"); + return ""; + } file.seek(file.size()-1); - int count = 0; - int lines = 100; + uint32_t count = 0; while ( (count < lines) && (file.pos() > 0) ) { QString ch = file.read(1); @@ -2032,8 +2036,10 @@ void MainWindow::setupDebugLogTab() { ui->debugLog->setPlainText("Loading debug log..."); QObject::connect(ui->refreshDebugButton, &QPushButton::clicked, [=] () { - DEBUG("refresh debug log clicked"); - ui->debugLog->setPlainText( readDebugLines() ); + uint32_t debugLines = ui->debugLines->text().trimmed().toInt(); + if (debugLines == 0) { debugLines = 50; } + DEBUG("refresh debug log clicked with debugLines=" << debugLines); + ui->debugLog->setPlainText( readDebugLines(debugLines) ); }); ui->debugLog->setPlainText( readDebugLines() ); diff --git a/src/mainwindow.h b/src/mainwindow.h index 1f0ea51..f4eaf05 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -85,7 +85,7 @@ private: void closeEvent(QCloseEvent* event); - QString readDebugLines(); + QString readDebugLines(uint32_t lines = 50); void setupSendTab(); void setupPeersTab(); void setupTransactionsTab(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index bdbbfdf..899abc5 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1164,7 +1164,24 @@ - + + + + Number of lines to show + + + + + + + true + + + 50 + + + +