diff --git a/src/init.cpp b/src/init.cpp index 5b9aa76f5622..21c7ee96a3c6 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -683,7 +683,8 @@ bool AppInit2(boost::thread_group& threadGroup) //ignore masternodes below protocol version nMasternodeMinProtocol = GetArg("-masternodeminprotocol", 0); - std::string strWalletFile = GetArg("-wallet", "wallet.dat"); + //define wallet + strWalletFile = GetArg("-wallet", "wallet.dat"); // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log @@ -701,6 +702,10 @@ bool AppInit2(boost::thread_group& threadGroup) if (!lock.try_lock()) return InitError(strprintf(_("Cannot obtain a lock on data directory %s. DarkCoin is probably already running."), strDataDir.c_str())); + //use _debug.log with -wallet option + if(strWalletFile != "wallet.dat") + strDebugFile = boost::filesystem::basename(strWalletFile) + "_debug.log"; + if (GetBoolArg("-shrinkdebugfile", !fDebug)) ShrinkDebugFile(); LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); diff --git a/src/util.cpp b/src/util.cpp index 7c3500b208b7..36fb5025d069 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -73,6 +73,8 @@ map > mapMultiArgs; bool fMasterNode = false; string strMasterNodePrivKey = ""; string strMasterNodeAddr = ""; +string strWalletFile = "wallet.dat"; +string strDebugFile = "debug.log"; int nInstantXDepth = 1; int nDarksendRounds = 2; int nAnonymizeDarkcoinAmount = 1000; @@ -250,7 +252,7 @@ static void DebugPrintInit() assert(fileout == NULL); assert(mutexDebugLog == NULL); - boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; + boost::filesystem::path pathDebug = GetDataDir() / strDebugFile; fileout = fopen(pathDebug.string().c_str(), "a"); if (fileout) setbuf(fileout, NULL); // unbuffered @@ -287,7 +289,7 @@ int LogPrint(const char* category, const char* pszFormat, ...) // reopen the log file, if requested if (fReopenDebugLog) { fReopenDebugLog = false; - boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; + boost::filesystem::path pathDebug = GetDataDir() / strDebugFile; if (freopen(pathDebug.string().c_str(),"a",fileout) != NULL) setbuf(fileout, NULL); // unbuffered } @@ -1287,7 +1289,7 @@ void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length) { void ShrinkDebugFile() { // Scroll debug.log if it's getting too big - boost::filesystem::path pathLog = GetDataDir() / "debug.log"; + boost::filesystem::path pathLog = GetDataDir() / strDebugFile; FILE* file = fopen(pathLog.string().c_str(), "r"); if (file && GetFilesize(file) > 10 * 1000000) { diff --git a/src/util.h b/src/util.h index 507ade862dfd..4b5a4a492c7f 100644 --- a/src/util.h +++ b/src/util.h @@ -137,6 +137,8 @@ extern int nLiquidityProvider; extern bool fEnableDarksend; extern int64 enforceMasternodePaymentsTime; extern std::string strMasterNodeAddr; +extern std::string strWalletFile; +extern std::string strDebugFile; extern int nMasternodeMinProtocol; extern int keysLoaded; extern bool fSucessfullyLoaded;