summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/systrace.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2010-05-07 16:18:41 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2010-05-07 16:18:41 +0000
commitfeecb7d4beed9dc58a82201acd692631cdf6d0b3 (patch)
tree4262720fc235b9ff8e896eb45d74a92549598d2e /rbutil/rbutilqt/systrace.cpp
parent227e619bbfeaf7d5d3112cc35a1865ff96129c5c (diff)
downloadrockbox-feecb7d4beed9dc58a82201acd692631cdf6d0b3.tar.gz
rockbox-feecb7d4beed9dc58a82201acd692631cdf6d0b3.tar.bz2
rockbox-feecb7d4beed9dc58a82201acd692631cdf6d0b3.zip
Add repeat counting to system trace.
This make the system trace check for repeating lines, and only print a "(last message repeated n lines.)" instead of the real message multiple times. This keeps the trace much shorter if messages are repeated. The drawback is that the replacement count message will only get printed on the next line getting traced, so until that happens it swallows the repeated lines. Before saving the systrace buffer is flushed, so this should not raise a problem. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25878 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/systrace.cpp')
-rw-r--r--rbutil/rbutilqt/systrace.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/rbutil/rbutilqt/systrace.cpp b/rbutil/rbutilqt/systrace.cpp
index 1b9de6b713..a1e8bd0239 100644
--- a/rbutil/rbutilqt/systrace.cpp
+++ b/rbutil/rbutilqt/systrace.cpp
@@ -24,6 +24,8 @@
#include "rbsettings.h"
QString SysTrace::debugbuffer;
+QString SysTrace::lastmessage;
+unsigned int SysTrace::repeat = 0;
SysTrace::SysTrace(QWidget *parent) : QDialog(parent)
{
@@ -41,6 +43,7 @@ SysTrace::SysTrace(QWidget *parent) : QDialog(parent)
void SysTrace::refresh(void)
{
int pos = ui.textTrace->verticalScrollBar()->value();
+ flush();
ui.textTrace->setHtml("<pre>" + debugbuffer + "</pre>");
ui.textTrace->verticalScrollBar()->setValue(pos);
QString oldlog = RbSettings::value(RbSettings::CachePath).toString()
@@ -54,6 +57,8 @@ void SysTrace::save(QString filename)
if(filename.isEmpty())
filename = RbSettings::value(RbSettings::CachePath).toString()
+ "/rbutil-trace.log";
+ // make sure any repeat detection is flushed
+ flush();
// 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 ");
@@ -91,11 +96,29 @@ void SysTrace::savePreviousTrace(void)
void SysTrace::debug(QtMsgType type, const char* msg)
{
(void)type;
- debugbuffer.append(msg);
- debugbuffer.append("\n");
+ if(lastmessage != msg) {
+ lastmessage = msg;
+ flush();
+ debugbuffer.append(msg);
+ debugbuffer.append("\n");
#if !defined(NODEBUG)
- fprintf(stderr, "%s\n", msg);
+ fprintf(stderr, "%s\n", msg);
#endif
+ repeat = 1;
+ }
+ else {
+ repeat++;
+ }
+}
+void SysTrace::flush(void)
+{
+ if(repeat > 1) {
+ debugbuffer.append(
+ QString(" (Last message repeasted %1 times.)\n").arg(repeat));
+#if !defined(NODEBUG)
+ fprintf(stderr, " (Last message repeated %i times.)\n", repeat);
+#endif
+ }
}