aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-07-23 17:01:08 +1000
committerGavin Andresen <gavinandresen@gmail.com>2013-08-22 11:05:45 +1000
commit47d0534368fbf0e3fb2cad7d05d60501d29f62aa (patch)
tree5294b7b4791a813980588600104f7b95839132b9
parenta73aa68b848f7fe41aa2e6a8721dbc7fdcfa8080 (diff)
Route qDebug() messages to debug.log
-rw-r--r--src/qt/bitcoin.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 52015b4751..5ab5d1f7ee 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -151,6 +151,19 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
QApplication::installTranslator(&translator);
}
+/* qDebug() message handler --> debug.log */
+#if QT_VERSION < 0x050000
+void DebugMessageHandler(QtMsgType type, const char * msg)
+{
+ OutputDebugStringF("%s\n", msg);
+}
+#else
+void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
+{
+ OutputDebugStringF("%s\n", qPrintable(msg));
+}
+#endif
+
#ifndef BITCOIN_QT_TEST
int main(int argc, char *argv[])
{
@@ -242,6 +255,13 @@ int main(int argc, char *argv[])
return 1;
}
+ // Install qDebug() message handler to route to debug.log:
+#if QT_VERSION < 0x050000
+ qInstallMsgHandler(DebugMessageHandler);
+#else
+ qInstallMessageHandler(DebugMessageHandler);
+#endif
+
SplashScreen splash(QPixmap(), 0);
if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false))
{