Browse Source

Test reading debug.log

pull/112/head
fekt 2 years ago
parent
commit
c435a818b4
  1. 46
      src/mainwindow.cpp

46
src/mainwindow.cpp

@ -2115,11 +2115,51 @@ void MainWindow::rescanButtonClicked(int number) {
// Call rescan RPC
rpc->rescan(rescanHeight, [=] (QJsonValue response){
qDebug() << "rescanning " << response;
qDebug() << "rescanning finished" << response;
});
/* TODO: Display progress somewhere by reading debug.log with QFileSystemWatcher
* or something similar / or use an available RPC and update rescan progress somewhere */
// TODO: Display progress somewhere by reading debug.log
#ifdef Q_OS_LINUX
auto debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, ".hush/HUSH3/debug.log");
if(!QFile(debugLocation).exists()) {
// legacy location
debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, ".komodo/HUSH3/debug.log");
}
#elif defined(Q_OS_DARWIN)
auto debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, "Library/Application Support/Hush/HUSH3/debug.log");
if(!QFile(debugLocation).exists()) {
// legacy location
debugLocation = QStandardPaths::locate(QStandardPaths::HomeLocation, "Library/Application Support/Komodo/HUSH3/debug.log");
}
#else
auto debugLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../../Hush/HUSH3/debug.log");
if(!QFile(debugLocation).exists()) {
// legacy location
debugLocation = QStandardPaths::locate(QStandardPaths::AppDataLocation, "../../Komodo/HUSH3/debug.log");
}
#endif
if(QFile(debugLocation).exists()){
qDebug() << "Found debug.log at "+ debugLocation;
QFile debugLog(debugLocation);
if(debugLog.open(QIODevice::ReadOnly)){
debugLog.seek(debugLog.size()-1);
int count = 0;
int lines = 25;
while ( (count < lines) && (debugLog.pos() > 0) )
{
QString ch = debugLog.read(1);
debugLog.seek(debugLog.pos()-2);
if (ch == "\n")
count++;
}
qDebug() << "debug.log =" + debugLog.readAll();
debugLog.close();
}else{
qDebug() <<"couldn't open debug.log for reading";
}
}
}
}

Loading…
Cancel
Save