Skip to content
7 changes: 6 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 <wallet>_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");
Expand Down
8 changes: 5 additions & 3 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ map<string, vector<string> > 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;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down