aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp2
-rw-r--r--src/qt/bitcoin.cpp4
-rw-r--r--src/rpcdump.cpp2
-rw-r--r--src/util.cpp10
-rw-r--r--src/util.h6
5 files changed, 16 insertions, 8 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 87c6e27072..0819e0dcaa 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -426,7 +426,7 @@ bool AppInit2(boost::thread_group& threadGroup)
// ********************************************************* Step 3: parameter-to-internal-flags
- fDebug = GetBoolArg("-debug", false);
+ if (mapMultiArgs.count("-debug")) fDebug = true;
fBenchmark = GetBoolArg("-benchmark", false);
mempool.fChecks = GetBoolArg("-checkmempool", RegTest());
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index a4d589e167..3ebf904394 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -155,12 +155,12 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans
#if QT_VERSION < 0x050000
void DebugMessageHandler(QtMsgType type, const char * msg)
{
- OutputDebugStringF("Bitcoin-Qt: %s\n", msg);
+ LogPrint("qt", "Bitcoin-Qt: %s\n", msg);
}
#else
void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg)
{
- OutputDebugStringF("Bitcoin-Qt: %s\n", qPrintable(msg));
+ LogPrint("qt", "Bitcoin-Qt: %s\n", qPrintable(msg));
}
#endif
diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp
index e166f76bf1..a6e2de6101 100644
--- a/src/rpcdump.cpp
+++ b/src/rpcdump.cpp
@@ -15,8 +15,6 @@
#include <boost/variant/get.hpp>
#include <boost/algorithm/string.hpp>
-#define printf OutputDebugStringF
-
using namespace json_spirit;
using namespace std;
diff --git a/src/util.cpp b/src/util.cpp
index 16c8f3fc17..466f6ddff6 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -233,8 +233,16 @@ static void DebugPrintInit()
mutexDebugLog = new boost::mutex();
}
-int OutputDebugStringF(const char* pszFormat, ...)
+int LogPrint(const char* category, const char* pszFormat, ...)
{
+ if (category != NULL)
+ {
+ if (!fDebug) return 0;
+ const vector<string>& categories = mapMultiArgs["-debug"];
+ if (find(categories.begin(), categories.end(), string(category)) == categories.end())
+ return 0;
+ }
+
int ret = 0; // Returns total number of characters written
if (fPrintToConsole)
{
diff --git a/src/util.h b/src/util.h
index d0bd16c1c9..a1b6c7fcdd 100644
--- a/src/util.h
+++ b/src/util.h
@@ -153,7 +153,9 @@ extern volatile bool fReopenDebugLog;
void RandAddSeed();
void RandAddSeedPerfmon();
-int ATTR_WARN_PRINTF(1,2) OutputDebugStringF(const char* pszFormat, ...);
+
+// Print to debug.log if -debug=category switch is given OR category is NULL.
+int ATTR_WARN_PRINTF(2,3) LogPrint(const char* category, const char* pszFormat, ...);
/*
Rationale for the real_strprintf / strprintf construction:
@@ -179,7 +181,7 @@ bool ATTR_WARN_PRINTF(1,2) error(const char *format, ...);
* __attribute__((format(printf,X,Y))) gets expanded to __attribute__((format(OutputDebugStringF,X,Y)))
* which confuses gcc.
*/
-#define printf OutputDebugStringF
+#define printf(...) LogPrint(NULL, __VA_ARGS__)
void LogException(std::exception* pex, const char* pszThread);
void PrintException(std::exception* pex, const char* pszThread);