summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/systrace.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2010-03-23 22:07:17 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2010-03-23 22:07:17 +0000
commit56199d3dfba2c2454c1226fac5d98e84ecf11cd1 (patch)
tree8a8e2dd58e9bb13279aa4b3427cca46261c5fe1f /rbutil/rbutilqt/systrace.cpp
parent492fafe8792bf21f034d34bbef0e3d38383fa989 (diff)
Save System Trace on exit and allow easy retrieval after restart.
The System Trace isn't preserved when quitting Rockbox Utility. Change this so the last trace is saved in the cache folder, and add a button to the trace window to allow easy saving it. Should help in cases where users have problems but restart Rockbox Utility before saving the trace. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25313 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/systrace.cpp')
-rw-r--r--rbutil/rbutilqt/systrace.cpp47
1 files changed, 39 insertions, 8 deletions
diff --git a/rbutil/rbutilqt/systrace.cpp b/rbutil/rbutilqt/systrace.cpp
index 1aed5c05b5..1b9de6b713 100644
--- a/rbutil/rbutilqt/systrace.cpp
+++ b/rbutil/rbutilqt/systrace.cpp
@@ -21,6 +21,7 @@
#include "systrace.h"
#include "ui_systracefrm.h"
+#include "rbsettings.h"
QString SysTrace::debugbuffer;
@@ -32,7 +33,8 @@ SysTrace::SysTrace(QWidget *parent) : QDialog(parent)
refresh();
connect(ui.buttonClose, SIGNAL(clicked()), this, SLOT(close()));
- connect(ui.buttonSave, SIGNAL(clicked()), this, SLOT(save()));
+ connect(ui.buttonSave, SIGNAL(clicked()), this, SLOT(saveCurrentTrace()));
+ connect(ui.buttonSavePrevious, SIGNAL(clicked()), this, SLOT(savePreviousTrace()));
connect(ui.buttonRefresh, SIGNAL(clicked()), this, SLOT(refresh()));
}
@@ -41,22 +43,51 @@ void SysTrace::refresh(void)
int pos = ui.textTrace->verticalScrollBar()->value();
ui.textTrace->setHtml("<pre>" + debugbuffer + "</pre>");
ui.textTrace->verticalScrollBar()->setValue(pos);
+ QString oldlog = RbSettings::value(RbSettings::CachePath).toString()
+ + "/rbutil-trace.log";
+ ui.buttonSavePrevious->setEnabled(QFileInfo(oldlog).isFile());
}
-void SysTrace::save(void)
+
+void SysTrace::save(QString filename)
{
- QString fp = QFileDialog::getSaveFileName(this, tr("Save system trace log"),
- QDir::homePath(), "*.log");
- if(fp == "")
- return;
-
- QFile fh(fp);
+ if(filename.isEmpty())
+ filename = RbSettings::value(RbSettings::CachePath).toString()
+ + "/rbutil-trace.log";
+ // append save date to the trace. Append it directly instead of using
+ // qDebug() as the handler might have been unregistered.
+ debugbuffer.append("[SysTrace] saving trace at ");
+ debugbuffer.append(QDateTime::currentDateTime().toString(Qt::ISODate));
+ debugbuffer.append("\n");
+ QFile fh(filename);
if(!fh.open(QIODevice::WriteOnly))
return;
fh.write(debugbuffer.toUtf8(), debugbuffer.size());
fh.close();
}
+void SysTrace::saveCurrentTrace(void)
+{
+ QString fp = QFileDialog::getSaveFileName(this, tr("Save system trace log"),
+ QDir::homePath(), "*.log");
+ if(!fp.isEmpty())
+ save(fp);
+}
+
+
+void SysTrace::savePreviousTrace(void)
+{
+ QString fp = QFileDialog::getSaveFileName(this, tr("Save system trace log"),
+ QDir::homePath(), "*.log");
+ if(fp.isEmpty())
+ return;
+
+ QString oldlog = RbSettings::value(RbSettings::CachePath).toString()
+ + "/rbutil-trace.log";
+ QFile::copy(oldlog, fp);
+ return;
+}
+
void SysTrace::debug(QtMsgType type, const char* msg)
{
(void)type;