From be3209e1fc77be71bd666adc97416610ffae06b7 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 3 Oct 2011 18:39:21 +0000 Subject: [PATCH] - when we have a runtime error, we now log the error text to error.log which will be located in the path where all log files are written. --- source/glest_game/main/main.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index a1c44bb1..459cb47c 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -334,9 +334,7 @@ public: } #endif - static void handleRuntimeError(const char *msg) { - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - + static void logError(const char *msg, bool confirmToConsole) { string errorLogFile = "error.log"; if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") { errorLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + errorLogFile; @@ -372,9 +370,17 @@ public: fclose(fp); } #endif - printf("Error saved to logfile [%s]\n",errorLogFile.c_str()); - fflush(stdout); + if(confirmToConsole == true) { + printf("Error saved to logfile [%s]\n",errorLogFile.c_str()); + fflush(stdout); + } } + } + + static void handleRuntimeError(const char *msg) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + logError(msg,true); Program *program = Program::getInstance(); @@ -470,6 +476,8 @@ public: if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + logError(errMsg.c_str(),false); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,errMsg.c_str()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,errMsg.c_str());