Browse Source

Support dragonx debug log and custom number of lines

pull/148/head
Duke 4 months ago
parent
commit
702619a8e0
  1. 24
      src/mainwindow.cpp
  2. 2
      src/mainwindow.h
  3. 19
      src/mainwindow.ui

24
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() );

2
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();

19
src/mainwindow.ui

@ -1164,7 +1164,24 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<item row="0" column="1">
<widget class="QLabel" name="debugLabel">
<property name="text">
<string>Number of lines to show</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="debugLines">
<property name="enabled">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>50</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QPlainTextEdit" name="debugLog">
<property name="plainText">
<string/>

Loading…
Cancel
Save