[rkward-cvs] SF.net SVN: rkward:[2619] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Fri Aug 21 12:58:58 UTC 2009
Revision: 2619
http://rkward.svn.sourceforge.net/rkward/?rev=2619&view=rev
Author: tfry
Date: 2009-08-21 12:58:58 +0000 (Fri, 21 Aug 2009)
Log Message:
-----------
Redirect debug output to a temporary file.
This should a) keep the console clean b) be accessible even if started without terminal c) work on windows.
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/main.cpp
trunk/rkward/rkward/settings/rksettingsmoduledebug.cpp
trunk/rkward/rkward/settings/rksettingsmoduledebug.h
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2009-08-21 12:57:11 UTC (rev 2618)
+++ trunk/rkward/ChangeLog 2009-08-21 12:58:58 UTC (rev 2619)
@@ -1,3 +1,4 @@
+- Debug output (previously sent to stderr) is now written to a temporary file
- On plugin help pages, display a link to invoke the plugin
- Tolerate missing libraries in testing framework TODO: - Encourage running 'make plugintests' after install in all relevant places
- Double-clicking an item in the workspace browser now opens an object viewer, or (if possible) editor
Modified: trunk/rkward/rkward/main.cpp
===================================================================
--- trunk/rkward/rkward/main.cpp 2009-08-21 12:57:11 UTC (rev 2618)
+++ trunk/rkward/rkward/main.cpp 2009-08-21 12:58:58 UTC (rev 2619)
@@ -53,11 +53,16 @@
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
+#include <ktemporaryfile.h>
#include <qstring.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#include "rkward.h"
#include "rkwardapplication.h"
+#include "settings/rksettingsmoduledebug.h"
#ifdef Q_WS_WIN
// these are needed for the exit hack.
@@ -75,6 +80,14 @@
static KCmdLineOptions options;
+void RKDebugMessageOutput (QtMsgType type, const char *msg) {
+ if (type == QtFatalMsg) {
+ fprintf (stderr, "%s\n", msg);
+ }
+ RKSettingsModuleDebug::debug_file->write (msg);
+ RKSettingsModuleDebug::debug_file->write ("\n");
+}
+
int main(int argc, char *argv[]) {
options.add ("evaluate <Rcode>", ki18n ("After starting (and after loading the specified workspace, if applicable), evaluate the given R code."), 0);
options.add ("debug-level <level>", ki18n ("Verbosity of debug messages (0-5)"), "2");
@@ -130,6 +143,11 @@
stoptions->evaluate = args->getOption ("evaluate");
RKWardApplication app;
+ // install message handler *after* the componentData has been initialized
+ RKSettingsModuleDebug::debug_file = new KTemporaryFile ();
+ RKSettingsModuleDebug::debug_file->setAutoRemove (false);
+ if (RKSettingsModuleDebug::debug_file->open ()) qInstallMsgHandler (RKDebugMessageOutput);
+
if (app.isSessionRestored ()) {
RESTORE(RKWardMainWindow); // well, whatever this is supposed to do -> TODO
} else {
@@ -139,6 +157,11 @@
// do it!
int status = app.exec ();
+
+ qInstallMsgHandler (0);
+ RK_DO (qDebug ("Full debug output is at %s", qPrintable (RKSettingsModuleDebug::debug_file->fileName ())), APP, DL_INFO);
+ RKSettingsModuleDebug::debug_file->close ();
+
#ifdef Q_WS_WIN
// HACK: Somehow, if we created a windows graph-device during runtime (possibly also on other conditions), we just can't exit cleanly anymore.
// We get out of the event loop, but once we return from main (including using _endthread(), _exit(), exit(), abort(), raise(SIGSEGV),
Modified: trunk/rkward/rkward/settings/rksettingsmoduledebug.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduledebug.cpp 2009-08-21 12:57:11 UTC (rev 2618)
+++ trunk/rkward/rkward/settings/rksettingsmoduledebug.cpp 2009-08-21 12:58:58 UTC (rev 2619)
@@ -2,7 +2,7 @@
rksettingsmoduledebug description
-------------------
begin : Tue Oct 23 2007
- copyright : (C) 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2007, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -19,6 +19,7 @@
#include <klocale.h>
#include <kconfig.h>
#include <kconfiggroup.h>
+#include <ktemporaryfile.h>
#include <qlayout.h>
#include <qlabel.h>
@@ -31,6 +32,8 @@
#include "../rkglobals.h"
#include "../debug.h"
+KTemporaryFile* RKSettingsModuleDebug::debug_file = 0;
+
RKSettingsModuleDebug::RKSettingsModuleDebug (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
RK_TRACE (SETTINGS);
@@ -85,6 +88,12 @@
main_vbox->addWidget (command_timeout_box);
main_vbox->addStretch ();
+
+ if (debug_file) {
+ label = new QLabel (i18n ("<i>Note:</i> Debug output is written to %1", debug_file->fileName ()));
+ main_vbox->addWidget (label);
+ main_vbox->addStretch ();
+ }
}
RKSettingsModuleDebug::~RKSettingsModuleDebug () {
Modified: trunk/rkward/rkward/settings/rksettingsmoduledebug.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduledebug.h 2009-08-21 12:57:11 UTC (rev 2618)
+++ trunk/rkward/rkward/settings/rksettingsmoduledebug.h 2009-08-21 12:58:58 UTC (rev 2619)
@@ -2,7 +2,7 @@
rksettingsmoduledebug - description
-------------------
begin : Tue Oct 23 2007
- copyright : (C) 2007 by Thomas Friedrichsmeier
+ copyright : (C) 2007, 2009 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -21,6 +21,7 @@
class RKSpinBox;
class QButtonGroup;
+class KTemporaryFile;
/**
configuration for the Command Editor windows
@@ -46,6 +47,9 @@
// static members are declared in debug.h and defined in main.cpp
public slots:
void settingChanged (int);
+public:
+ // public for internal reason, only! Do not mess with this!
+ static KTemporaryFile* debug_file;
private:
RKSpinBox* command_timeout_box;
RKSpinBox* debug_level_box;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list