[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3443: Add some debug logging that may help track down whatever pol (vidalia/trunk/src/vidalia)
Author: edmanm
Date: 2009-01-16 15:15:44 -0500 (Fri, 16 Jan 2009)
New Revision: 3443
Modified:
vidalia/trunk/src/vidalia/helperprocess.cpp
vidalia/trunk/src/vidalia/helperprocess.h
Log:
Add some debug logging that may help track down whatever polipo-related issues
coderman was looking into recently.
Modified: vidalia/trunk/src/vidalia/helperprocess.cpp
===================================================================
--- vidalia/trunk/src/vidalia/helperprocess.cpp 2009-01-16 07:32:55 UTC (rev 3442)
+++ vidalia/trunk/src/vidalia/helperprocess.cpp 2009-01-16 20:15:44 UTC (rev 3443)
@@ -39,7 +39,10 @@
*/
#include <QString>
-
+#include <QFileInfo>
+#include <stringutil.h>
+#include <vidalia.h>
+
#include "helperprocess.h"
@@ -50,12 +53,46 @@
// Call error handling routine on errors
QObject::connect(this, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(onError(QProcess::ProcessError)));
+
+ // Call output handling routines on process output
+ QObject::connect(this, SIGNAL(readyReadStandardError()),
+ this, SLOT(onReadyReadStandardError()));
+ QObject::connect(this, SIGNAL(readyReadStandardOutput()),
+ this, SLOT(onReadyReadStandardOutput()));
}
+/** Invoked when output is written to the process's stderr. */
+void
+HelperProcess::onReadyReadStandardError()
+{
+ QString output = QString(readAllStandardError());
+ foreach (QString line, output.split("\n")) {
+ vInfo("(%1:stderr): %2").arg(_processName).arg(line);
+ }
+}
+
+/** Invoked when output is written to the process's stdout. */
+void
+HelperProcess::onReadyReadStandardOutput()
+{
+ QString output = QString(readAllStandardOutput());
+ foreach (QString line, output.split("\n")) {
+ vInfo("(%1:stdout): %2").arg(_processName).arg(line);
+ }
+}
+
/** Start the specified application. */
void
HelperProcess::start(const QString &app, const QStringList &args)
{
+ // Remember the executable name of the process
+ QFileInfo fi(app);
+ _processName = fi.fileName();
+
+ // Log the process name and arguments
+ vNotice("Launching helper process '%1' with arguments '%2'").arg(app)
+ .arg(string_format_arguments(args));
+
// Start the specified application
QProcess::start(app, args, QIODevice::ReadOnly | QIODevice::Text);
}
@@ -66,6 +103,8 @@
{
// Pass up error messages on startup, but ignore the rest
if (error == QProcess::FailedToStart) {
+ vWarn("Helper process '%1' failed to start: %2").arg(_processName)
+ .arg(errorString());
emit startFailed(errorString());
}
}
Modified: vidalia/trunk/src/vidalia/helperprocess.h
===================================================================
--- vidalia/trunk/src/vidalia/helperprocess.h 2009-01-16 07:32:55 UTC (rev 3442)
+++ vidalia/trunk/src/vidalia/helperprocess.h 2009-01-16 20:15:44 UTC (rev 3443)
@@ -56,13 +56,20 @@
/** Returns true iff process is not running. */
bool isDone() const;
+signals:
+ /** Invoked when start() fails. */
+ void startFailed(const QString &errorMessage);
+
private slots:
/** Invoked when underlying QProcess fails. */
void onError(QProcess::ProcessError error);
+ /** Invoked when output is written to the process's stderr. */
+ void onReadyReadStandardError();
+ /** Invoked when output is written to the process's stdout. */
+ void onReadyReadStandardOutput();
-signals:
- /** Invoked when start() fails. */
- void startFailed(const QString &errorMessage);
+private:
+ QString _processName;
};
#endif