From dac2ec8357d5c644f4f1b98eaafb4856282c41b5 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 21 Jun 2010 21:03:21 +0200 Subject: [PATCH] Changed: #991 Make sure all debug files are created in log directory --- code/nel/src/misc/displayer.cpp | 4 +- code/ryzom/client/src/client.cpp | 40 +++++++++---------- code/ryzom/client/src/commands.cpp | 4 +- .../client/src/entity_animation_manager.cpp | 2 +- code/ryzom/client/src/far_tp.cpp | 4 +- code/ryzom/client/src/init.cpp | 2 +- code/ryzom/client/src/init_main_loop.cpp | 2 +- .../src/interface_v3/action_handler_debug.cpp | 2 +- .../src/interface_v3/interface_parser.cpp | 2 +- code/ryzom/client/src/login.cpp | 13 +++--- code/ryzom/client/src/main_loop.cpp | 2 +- code/ryzom/client/src/network_connection.cpp | 2 +- code/ryzom/client/src/sheet_manager.cpp | 4 +- 13 files changed, 41 insertions(+), 42 deletions(-) diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 4f4e0866a..717aeded3 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -669,7 +669,9 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m { // yoyo: allow only to send the crash report once. Because users usually click ignore, // which create noise into list of bugs (once a player crash, it will surely continues to do it). - if (ReportDebug == report (args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), "", subject, body, true, 2, true, 1, !isCrashAlreadyReported(), IgnoreNextTime, NL_CRASH_DUMP_FILE)) + std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE; + + if (ReportDebug == report (args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), "", subject, body, true, 2, true, 1, !isCrashAlreadyReported(), IgnoreNextTime, filename.c_str())) { INelContext::getInstance().setDebugNeedAssert(true); } diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index cfe136cbb..93a243949 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -95,8 +95,8 @@ static CTcpSock CrashCounterSock; void quitCrashReport () { - if (NLMISC::CFile::fileExists("ryzom_started")) - CFile::deleteFile ("ryzom_started"); + if (NLMISC::CFile::fileExists(getLogDirectory() + "ryzom_started")) + CFile::deleteFile (getLogDirectory() + "ryzom_started"); // must disconnect now, else could crash at dtor time because nldebug -> access a new INelContext() contReset(CrashCounterSock); } @@ -285,7 +285,7 @@ INT_PTR CALLBACK ReportDialogProc( void initCrashReport () { // - bool crashed = CFile::isExists ("ryzom_started"); + bool crashed = CFile::isExists (getLogDirectory() + "ryzom_started"); bool during_release = false; bool exception_catched = false; bool breakpointed = false; @@ -293,22 +293,21 @@ void initCrashReport () bool report_failed = false; bool report_refused = false; bool report_sent = false; - if (crashed && CFile::isExists ("during_release")) - during_release = CFile::getFileModificationDate ("ryzom_started") <= CFile::getFileModificationDate ("during_release"); - if (crashed && CFile::isExists ("exception_catched")) - exception_catched = CFile::getFileModificationDate ("ryzom_started") <= CFile::getFileModificationDate ("exception_catched"); - if (crashed && CFile::isExists ("breakpointed")) - breakpointed = CFile::getFileModificationDate ("ryzom_started") <= CFile::getFileModificationDate ("breakpointed"); - if (crashed && CFile::isExists ("nel_debug.dmp")) - dumped = CFile::getFileModificationDate ("ryzom_started") <= CFile::getFileModificationDate ("nel_debug.dmp"); - if (crashed && CFile::isExists ("report_failed")) - report_failed = CFile::getFileModificationDate ("ryzom_started") <= CFile::getFileModificationDate ("report_failed"); - if (crashed && CFile::isExists ("report_refused")) - report_refused = CFile::getFileModificationDate ("ryzom_started") <= CFile::getFileModificationDate ("report_refused"); - if (crashed && CFile::isExists ("report_sent")) - report_sent = CFile::getFileModificationDate ("ryzom_started") <= CFile::getFileModificationDate ("report_sent"); - FILE *file = fopen ("ryzom_started", "wb"); - fclose (file); + if (crashed && CFile::isExists (getLogDirectory() + "during_release")) + during_release = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "during_release"); + if (crashed && CFile::isExists (getLogDirectory() + "exception_catched")) + exception_catched = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "exception_catched"); + if (crashed && CFile::isExists (getLogDirectory() + "breakpointed")) + breakpointed = CFile::getFileModificationDate ("ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "breakpointed"); + if (crashed && CFile::isExists (getLogDirectory() + "nel_debug.dmp")) + dumped = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "nel_debug.dmp"); + if (crashed && CFile::isExists (getLogDirectory() + "report_failed")) + report_failed = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "report_failed"); + if (crashed && CFile::isExists (getLogDirectory() + "report_refused")) + report_refused = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "report_refused"); + if (crashed && CFile::isExists (getLogDirectory() + "report_sent")) + report_sent = CFile::getFileModificationDate (getLogDirectory() + "ryzom_started") <= CFile::getFileModificationDate (getLogDirectory() + "report_sent"); + CFile::createEmptyFile(getLogDirectory() + "ryzom_started"); connect(); if (report_sent) send("/?crashtype=REPORT_SENT"); @@ -580,8 +579,7 @@ int main(int argc, char **argv) //ICommand::execute("iFileAccessLogClear",*NLMISC::InfoLog); #endif - FILE *file = fopen ("during_release", "wb"); - fclose (file); + CFile::createEmptyFile(getLogDirectory() + "during_release"); #ifdef TEST_CRASH_COUNTER if (string(cmdline) == "/release") diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index 46e42cd9f..a31619936 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -376,7 +376,7 @@ NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", " CBitmap btm; Driver->getBuffer(btm); - string filename = CFile::findNewFile ("screenshot.jpg"); + string filename = CFile::findNewFile (getLogDirectory() + "screenshot.jpg"); COFile fs(filename); btm.writeJPG(fs, quality); sys += "AttachedFile "+filename+" "; @@ -390,7 +390,7 @@ NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", " if (ClientCfg.Local) sys += "ShardName OFFLINE "; - FILE *fp = fopen ("bug_report.txt", "wb"); + FILE *fp = fopen (std::string(getLogDirectory() + "bug_report.txt").c_str(), "wb"); if (fp != NULL) { string res = addSlashR(getDebugInformation()); diff --git a/code/ryzom/client/src/entity_animation_manager.cpp b/code/ryzom/client/src/entity_animation_manager.cpp index c91192e83..0e7e3ac7a 100644 --- a/code/ryzom/client/src/entity_animation_manager.cpp +++ b/code/ryzom/client/src/entity_animation_manager.cpp @@ -179,7 +179,7 @@ void CEntityAnimationManager::load(NLMISC::IProgressCallback &/* progress */, bo release(); // Log in the animation file. - setDebugOutput("animation.dbg"); + setDebugOutput(getLogDirectory() + "animation.dbg"); // Create the animation set for all entities. _AnimationSet = Driver->createAnimationSet(); diff --git a/code/ryzom/client/src/far_tp.cpp b/code/ryzom/client/src/far_tp.cpp index a81198a8f..64930b2ce 100644 --- a/code/ryzom/client/src/far_tp.cpp +++ b/code/ryzom/client/src/far_tp.cpp @@ -168,7 +168,7 @@ const std::string& CLoginStateMachine::toString(CLoginStateMachine::TEvent event { \ COFile outputF; \ string sLog = NLMISC::toString("[%s] %s -> %s\n", CLoginStateMachine::toString(ev).c_str(), CLoginStateMachine::toString(_CurrentState).c_str(), CLoginStateMachine::toString(stateId).c_str()); \ - if ( outputF.open( "error_join.log", true, true ) ) \ + if ( outputF.open( getLogDirectory() + "error_join.log", true, true ) ) \ { \ outputF.serialBuffer( (uint8*)(&sLog[0]), (uint)sLog.size() ); \ outputF.close(); \ @@ -903,7 +903,7 @@ retryJoinEdit: try { COFile outputF; - if ( outputF.open( "error_join.log", true, true ) ) + if ( outputF.open( getLogDirectory() + "error_join.log", true, true ) ) { time_t currentTime; time( ¤tTime ); diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index c0ab07197..9f19b4844 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -702,7 +702,7 @@ void prelogInit() // Client.Log displayer nlassert( !ErrorLog->getDisplayer("CLIENT.LOG") ); - CFileDisplayer *ClientLogDisplayer = new CFileDisplayer("client.log", true, "CLIENT.LOG"); + CFileDisplayer *ClientLogDisplayer = new CFileDisplayer(getLogDirectory() + "client.log", true, "CLIENT.LOG"); DebugLog->addDisplayer (ClientLogDisplayer); InfoLog->addDisplayer (ClientLogDisplayer); WarningLog->addDisplayer (ClientLogDisplayer); diff --git a/code/ryzom/client/src/init_main_loop.cpp b/code/ryzom/client/src/init_main_loop.cpp index dc1967f6b..893b40565 100644 --- a/code/ryzom/client/src/init_main_loop.cpp +++ b/code/ryzom/client/src/init_main_loop.cpp @@ -1306,7 +1306,7 @@ void initMainLoop() // Display and save profile to a File. CLog log; - CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile("profile_startup.log")); + CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile(getLogDirectory() + "profile_startup.log")); log.addDisplayer(&fileDisplayer); // display NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(&log, CHTimer::TotalTime, true, 48, 2); diff --git a/code/ryzom/client/src/interface_v3/action_handler_debug.cpp b/code/ryzom/client/src/interface_v3/action_handler_debug.cpp index aa59577c9..b9f1bade0 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_debug.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_debug.cpp @@ -151,7 +151,7 @@ class CAHProfileTexture : public IActionHandler // Display and save profile to a File. CLog log; - CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile("texture.log")); + CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile(getLogDirectory() + "texture.log")); CStdDisplayer stdDisplayer; log.addDisplayer(&fileDisplayer); log.addDisplayer(&stdDisplayer); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index a97699542..b5121fa2c 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -677,7 +677,7 @@ bool CInterfaceParser::parseInterface (const std::vector & strings, NLMISC::CHTimer::endBench(); // Display and save profile to a File. CLog log; - CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile("profile_parseInterface.log")); + CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile(getLogDirectory() + "profile_parseInterface.log")); log.addDisplayer(&fileDisplayer); // diplay NLMISC::CHTimer::displayHierarchicalByExecutionPathSorted(&log, CHTimer::TotalTime, true, 48, 2); diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index 6c06e2b3c..7c79ff564 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -206,7 +206,7 @@ void createOptionalCatUI() void initEula() { CInterfaceManager *pIM = CInterfaceManager::getInstance(); - if (!ClientCfg.SkipEULA && CFile::fileExists("show_eula")) + if (!ClientCfg.SkipEULA && CFile::fileExists(getLogDirectory() + "show_eula")) { pIM->getDbProp("UI:VARIABLES:SCREEN")->setValue32(UI_VARIABLES_SCREEN_EULA); @@ -599,9 +599,7 @@ void loginMainLoop() // the patcher to overwrite them) // create a file to prompt eula next time - FILE *file = fopen ("show_eula", "wb"); - fclose (file); - + CFile::createEmptyFile(getLogDirectory() + "show_eula"); if (taskResult == BGDownloader::TaskResult_Error) { @@ -1707,9 +1705,10 @@ class CAHReboot : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* sParams */) { nlinfo("CAHReboot called"); + // create a file to prompt eula next time - FILE *file = fopen ("show_eula", "wb"); - fclose (file); + CFile::createEmptyFile(getLogDirectory() + "show_eula"); + CInterfaceManager *im = CInterfaceManager::getInstance(); try { @@ -1747,7 +1746,7 @@ class CAHAcceptEula : public IActionHandler virtual void execute (CCtrlBase * /* pCaller */, const string &/* sParams */) { nlinfo("CAHAcceptEula called"); - CFile::deleteFile("show_eula"); + CFile::deleteFile(getLogDirectory() + "show_eula"); LoginSM.pushEvent(CLoginStateMachine::ev_accept_eula); // if (ClientCfg.R2Mode) diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index f1e6347e7..bcf221601 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -518,7 +518,7 @@ void testLaunchProfile() // Display and save profile to a File. CLog log; - CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile("profile.log")); + CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile(getLogDirectory() + "profile.log")); CStdDisplayer stdDisplayer; log.addDisplayer(&fileDisplayer); log.addDisplayer(&stdDisplayer); diff --git a/code/ryzom/client/src/network_connection.cpp b/code/ryzom/client/src/network_connection.cpp index 751dd74a7..b309a9a99 100644 --- a/code/ryzom/client/src/network_connection.cpp +++ b/code/ryzom/client/src/network_connection.cpp @@ -133,7 +133,7 @@ void initReceiveLog() { try { - ReceiveLogDisp = new CFileDisplayer( "ReceiveLog.log" ); + ReceiveLogDisp = new CFileDisplayer( getLogDirectory() + "ReceiveLog.log" ); ReceiveLogger.addDisplayer( ReceiveLogDisp ); //ReceiveLogger.displayNL( "Searching for param LogReceive in the config file..." ); NCConfigFile.load( string( "client.cfg" ) ); diff --git a/code/ryzom/client/src/sheet_manager.cpp b/code/ryzom/client/src/sheet_manager.cpp index 810e7a10b..fff3c5162 100644 --- a/code/ryzom/client/src/sheet_manager.cpp +++ b/code/ryzom/client/src/sheet_manager.cpp @@ -598,7 +598,7 @@ void CSheetManager::release() void CSheetManager::load(NLMISC::IProgressCallback &callBack, bool updatePackedSheet, bool needComputeVS, bool dumpVSIndex) { // Open The Item Association File - if(!fItemAssoc.open("item_association.dbg", false, true)) + if(!fItemAssoc.open(getLogDirectory() + "item_association.dbg", false, true)) nlwarning("CSheetManager::load: Cannot Open the 'item_association.txt'."); else ItemAssocFileOpen = true; @@ -1020,7 +1020,7 @@ void CSheetManager::dumpVisualSlots() // *************************************************************************** void CSheetManager::dumpVisualSlotsIndex() { - FILE * vsIndexFile = fopen("vs_index.txt","w"); + FILE * vsIndexFile = fopen(std::string(getLogDirectory() + "vs_index.txt").c_str(),"w"); if( vsIndexFile ) { for (uint i=0; i < SLOTTYPE::NB_SLOT; ++i)