diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2009-08-15 17:02:25 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2009-08-15 17:02:25 +0000 |
commit | 426bfa8d037e458bd58a4c2dca82cbddae2a2f66 (patch) | |
tree | ae7250597cec8a9a1dcbd680e044204ca331cc27 /rbutil/rbutilqt/systrace.cpp | |
parent | 2402aecbb5eeb82c5920f9d837cd287581c11c05 (diff) | |
download | rockbox-426bfa8d037e458bd58a4c2dca82cbddae2a2f66.tar.gz rockbox-426bfa8d037e458bd58a4c2dca82cbddae2a2f66.tar.bz2 rockbox-426bfa8d037e458bd58a4c2dca82cbddae2a2f66.zip |
rbutil: add a errorlog function into rbutil and the possibility to save a log if a error happens. (thanks to bluebrother for the trace functionality)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22329 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/systrace.cpp')
-rw-r--r-- | rbutil/rbutilqt/systrace.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/systrace.cpp b/rbutil/rbutilqt/systrace.cpp new file mode 100644 index 0000000000..b8f4fb8434 --- /dev/null +++ b/rbutil/rbutilqt/systrace.cpp @@ -0,0 +1,65 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Riebeling + * $Id$ + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include <QtGui> +#include "systrace.h" +#include "ui_systracefrm.h" + + +QString SysTrace::debugbuffer; + +SysTrace::SysTrace(QWidget *parent) : QDialog(parent) +{ + ui.setupUi(this); + ui.textTrace->setReadOnly(true); + refresh(); + + connect(ui.buttonClose, SIGNAL(clicked()), this, SLOT(close())); + connect(ui.buttonSave, SIGNAL(clicked()), this, SLOT(save())); + connect(ui.buttonRefresh, SIGNAL(clicked()), this, SLOT(refresh())); +} + +void SysTrace::refresh(void) +{ + int pos = ui.textTrace->verticalScrollBar()->value(); + ui.textTrace->setHtml("<pre>" + debugbuffer + "</pre>"); + ui.textTrace->verticalScrollBar()->setValue(pos); +} + +void SysTrace::save(void) +{ + QString fp = QFileDialog::getSaveFileName(this, tr("Save system trace log"), + QDir::homePath(), "*.log"); + + QFile fh(fp); + fh.open(QIODevice::WriteOnly); + fh.write(debugbuffer.toUtf8(), debugbuffer.size()); + fh.close(); +} + +void SysTrace::debug(QtMsgType type, const char* msg) +{ + debugbuffer.append(msg); + debugbuffer.append("\n"); +#if !defined(NODEBUG) + fprintf(stderr, "%s\n", msg); +#endif + +} + |