aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-09-18 20:38:08 +1000
committerGavin Andresen <gavinandresen@gmail.com>2013-09-18 20:39:25 +1000
commit881a85a22d76c875f519cd54388a419ec6f70857 (patch)
tree3f71daa59ac35c5dda44747c0b62dbc8602d8f1c /src/util.h
parente51321fb75f00194425e5ecc8ad77fd6762ec221 (diff)
Replace printf with LogPrintf / LogPrint
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/util.h b/src/util.h
index a1b6c7fcdd..a216aacdc9 100644
--- a/src/util.h
+++ b/src/util.h
@@ -156,6 +156,7 @@ void RandAddSeedPerfmon();
// 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, ...);
+#define LogPrintf(...) LogPrint(NULL, __VA_ARGS__)
/*
Rationale for the real_strprintf / strprintf construction:
@@ -175,14 +176,6 @@ std::string vstrprintf(const char *format, va_list ap);
bool ATTR_WARN_PRINTF(1,2) error(const char *format, ...);
-/* Redefine printf so that it directs output to debug.log
- *
- * Do this *after* defining the other printf-like functions, because otherwise the
- * __attribute__((format(printf,X,Y))) gets expanded to __attribute__((format(OutputDebugStringF,X,Y)))
- * which confuses gcc.
- */
-#define printf(...) LogPrint(NULL, __VA_ARGS__)
-
void LogException(std::exception* pex, const char* pszThread);
void PrintException(std::exception* pex, const char* pszThread);
void PrintExceptionContinue(std::exception* pex, const char* pszThread);
@@ -319,12 +312,12 @@ inline std::string HexStr(const T& vch, bool fSpaces=false)
template<typename T>
void PrintHex(const T pbegin, const T pend, const char* pszFormat="%s", bool fSpaces=true)
{
- printf(pszFormat, HexStr(pbegin, pend, fSpaces).c_str());
+ LogPrintf(pszFormat, HexStr(pbegin, pend, fSpaces).c_str());
}
inline void PrintHex(const std::vector<unsigned char>& vch, const char* pszFormat="%s", bool fSpaces=true)
{
- printf(pszFormat, HexStr(vch, fSpaces).c_str());
+ LogPrintf(pszFormat, HexStr(vch, fSpaces).c_str());
}
inline int64 GetPerformanceCounter()
@@ -562,7 +555,7 @@ template <typename Callable> void LoopForever(const char* name, Callable func,
{
std::string s = strprintf("bitcoin-%s", name);
RenameThread(s.c_str());
- printf("%s thread start\n", name);
+ LogPrintf("%s thread start\n", name);
try
{
while (1)
@@ -573,7 +566,7 @@ template <typename Callable> void LoopForever(const char* name, Callable func,
}
catch (boost::thread_interrupted)
{
- printf("%s thread stop\n", name);
+ LogPrintf("%s thread stop\n", name);
throw;
}
catch (std::exception& e) {
@@ -590,13 +583,13 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
RenameThread(s.c_str());
try
{
- printf("%s thread start\n", name);
+ LogPrintf("%s thread start\n", name);
func();
- printf("%s thread exit\n", name);
+ LogPrintf("%s thread exit\n", name);
}
catch (boost::thread_interrupted)
{
- printf("%s thread interrupt\n", name);
+ LogPrintf("%s thread interrupt\n", name);
throw;
}
catch (std::exception& e) {