diff options
| author | Pieter Wuille <[email protected]> | 2012-05-21 10:04:26 -0700 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2012-05-21 10:04:26 -0700 |
| commit | 63407fd6e29b29ee56c572d4c6789c3f305990fc (patch) | |
| tree | 01b23cb06beddaf4fd8e0ba62a2cccef318b5b1f /src/util.cpp | |
| parent | Merge pull request #1329 from laanwj/2012_05_addrremovewhitespace (diff) | |
| parent | Reopen debug.log on SIGHUP (diff) | |
| download | discoin-63407fd6e29b29ee56c572d4c6789c3f305990fc.tar.xz discoin-63407fd6e29b29ee56c572d4c6789c3f305990fc.zip | |
Merge pull request #917 from mndrix/reopen-log-file
Reopen log file on SIGHUP
Diffstat (limited to 'src/util.cpp')
| -rw-r--r-- | src/util.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util.cpp b/src/util.cpp index a82625c84..9e7a8c034 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -25,6 +25,7 @@ namespace boost { #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/foreach.hpp> +#include <boost/thread.hpp> #include <openssl/crypto.h> #include <openssl/rand.h> #include <stdarg.h> @@ -69,6 +70,7 @@ bool fTestNet = false; bool fNoListen = false; bool fLogTimestamps = false; CMedianFilter<int64> vTimeOffsets(200,0); +bool fReopenDebugLog = false; // Init openssl library multithreading support static CCriticalSection** ppmutexOpenSSL; @@ -207,6 +209,16 @@ inline int OutputDebugStringF(const char* pszFormat, ...) if (fileout) { static bool fStartedNewLine = true; + static boost::mutex mutexDebugLog; + boost::mutex::scoped_lock scoped_lock(mutexDebugLog); + + // reopen the log file, if requested + if (fReopenDebugLog) { + fReopenDebugLog = false; + boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; + if (freopen(pathDebug.string().c_str(),"a",fileout) != NULL) + setbuf(fileout, NULL); // unbuffered + } // Debug print useful for profiling if (fLogTimestamps && fStartedNewLine) |