- bugfixes for debuglog filelist which crashes on windows platform on program exit
This commit is contained in:
parent
60f2b035e7
commit
bd12b10e29
|
@ -109,7 +109,7 @@ protected:
|
||||||
static string lockfilename;
|
static string lockfilename;
|
||||||
static int lockFileCountIndex;
|
static int lockFileCountIndex;
|
||||||
|
|
||||||
static std::map<DebugType,SystemFlagsType> debugLogFileList;
|
static std::map<DebugType,SystemFlagsType> *debugLogFileList;
|
||||||
static bool haveSpecialOutputCommandLineOption;
|
static bool haveSpecialOutputCommandLineOption;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ public:
|
||||||
~SystemFlags();
|
~SystemFlags();
|
||||||
|
|
||||||
static void init(bool haveSpecialOutputCommandLineOption);
|
static void init(bool haveSpecialOutputCommandLineOption);
|
||||||
static SystemFlagsType & getSystemSettingType(DebugType type) { return debugLogFileList[type]; }
|
static SystemFlagsType & getSystemSettingType(DebugType type) { return (*debugLogFileList)[type]; }
|
||||||
static size_t httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
|
static size_t httpWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data);
|
||||||
static std::string getHTTP(std::string URL,CURL *handle=NULL, int timeOut=-1);
|
static std::string getHTTP(std::string URL,CURL *handle=NULL, int timeOut=-1);
|
||||||
static std::string escapeURL(std::string URL, CURL *handle=NULL);
|
static std::string escapeURL(std::string URL, CURL *handle=NULL);
|
||||||
|
|
|
@ -39,7 +39,7 @@ using namespace Shared::PlatformCommon;
|
||||||
namespace Shared{ namespace Util{
|
namespace Shared{ namespace Util{
|
||||||
|
|
||||||
// Init statics
|
// Init statics
|
||||||
std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType> SystemFlags::debugLogFileList;
|
std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType> *SystemFlags::debugLogFileList = NULL;
|
||||||
int SystemFlags::lockFile = -1;
|
int SystemFlags::lockFile = -1;
|
||||||
int SystemFlags::lockFileCountIndex = -1;
|
int SystemFlags::lockFileCountIndex = -1;
|
||||||
string SystemFlags::lockfilename = "";
|
string SystemFlags::lockfilename = "";
|
||||||
|
@ -174,14 +174,17 @@ void SystemFlags::init(bool haveSpecialOutputCommandLineOption) {
|
||||||
//printf("SystemFlags::init CALLED, SystemFlags::debugLogFileList.size() = %d\n",SystemFlags::debugLogFileList.size());
|
//printf("SystemFlags::init CALLED, SystemFlags::debugLogFileList.size() = %d\n",SystemFlags::debugLogFileList.size());
|
||||||
|
|
||||||
SystemFlags::haveSpecialOutputCommandLineOption = haveSpecialOutputCommandLineOption;
|
SystemFlags::haveSpecialOutputCommandLineOption = haveSpecialOutputCommandLineOption;
|
||||||
if(SystemFlags::debugLogFileList.size() == 0) {
|
//if(SystemFlags::debugLogFileList.size() == 0) {
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem);
|
if(SystemFlags::debugLogFileList == NULL) {
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugNetwork] = SystemFlags::SystemFlagsType(SystemFlags::debugNetwork);
|
SystemFlags::debugLogFileList = new std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>();
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugPerformance] = SystemFlags::SystemFlagsType(SystemFlags::debugPerformance);
|
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch);
|
(*SystemFlags::debugLogFileList)[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem);
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands);
|
(*SystemFlags::debugLogFileList)[SystemFlags::debugNetwork] = SystemFlags::SystemFlagsType(SystemFlags::debugNetwork);
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugLUA] = SystemFlags::SystemFlagsType(SystemFlags::debugLUA);
|
(*SystemFlags::debugLogFileList)[SystemFlags::debugPerformance] = SystemFlags::SystemFlagsType(SystemFlags::debugPerformance);
|
||||||
SystemFlags::debugLogFileList[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError);
|
(*SystemFlags::debugLogFileList)[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch);
|
||||||
|
(*SystemFlags::debugLogFileList)[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands);
|
||||||
|
(*SystemFlags::debugLogFileList)[SystemFlags::debugLUA] = SystemFlags::SystemFlagsType(SystemFlags::debugLUA);
|
||||||
|
(*SystemFlags::debugLogFileList)[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(threadLogger == NULL) {
|
if(threadLogger == NULL) {
|
||||||
|
@ -247,16 +250,19 @@ void SystemFlags::Close() {
|
||||||
threadLogger = NULL;
|
threadLogger = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::debugLogFileList.size() > 0) {
|
if(SystemFlags::debugLogFileList != NULL) {
|
||||||
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("START Closing logfiles\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("START Closing logfiles\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList.begin();
|
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
|
||||||
iterMap != SystemFlags::debugLogFileList.end(); iterMap++) {
|
iterMap != SystemFlags::debugLogFileList->end(); iterMap++) {
|
||||||
SystemFlags::SystemFlagsType ¤tDebugLog = iterMap->second;
|
SystemFlags::SystemFlagsType ¤tDebugLog = iterMap->second;
|
||||||
currentDebugLog.Close();
|
currentDebugLog.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete SystemFlags::debugLogFileList;
|
||||||
|
SystemFlags::debugLogFileList = NULL;
|
||||||
}
|
}
|
||||||
if(SystemFlags::lockFile != -1) {
|
if(SystemFlags::lockFile != -1) {
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
@ -273,7 +279,7 @@ void SystemFlags::Close() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::debugLogFileList.size() > 0) {
|
if(SystemFlags::debugLogFileList != NULL) {
|
||||||
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("END Closing logfiles\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("END Closing logfiles\n");
|
||||||
}
|
}
|
||||||
|
@ -281,10 +287,10 @@ void SystemFlags::Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
if(SystemFlags::debugLogFileList.size() == 0) {
|
if(SystemFlags::debugLogFileList == NULL) {
|
||||||
SystemFlags::init(false);
|
SystemFlags::init(false);
|
||||||
}
|
}
|
||||||
SystemFlags::SystemFlagsType ¤tDebugLog = SystemFlags::debugLogFileList[type];
|
SystemFlags::SystemFlagsType ¤tDebugLog = (*SystemFlags::debugLogFileList)[type];
|
||||||
if(currentDebugLog.enabled == false) {
|
if(currentDebugLog.enabled == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -316,10 +322,10 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
|
|
||||||
|
|
||||||
void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugTime) {
|
void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugTime) {
|
||||||
if(SystemFlags::debugLogFileList.size() == 0) {
|
if(SystemFlags::debugLogFileList == NULL) {
|
||||||
SystemFlags::init(false);
|
SystemFlags::init(false);
|
||||||
}
|
}
|
||||||
SystemFlags::SystemFlagsType ¤tDebugLog = SystemFlags::debugLogFileList[type];
|
SystemFlags::SystemFlagsType ¤tDebugLog = (*SystemFlags::debugLogFileList)[type];
|
||||||
if(currentDebugLog.enabled == false) {
|
if(currentDebugLog.enabled == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -345,8 +351,8 @@ void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugT
|
||||||
|
|
||||||
// If the file is already open (shared) by another debug type
|
// If the file is already open (shared) by another debug type
|
||||||
// do not over-write the file but share the stream pointer
|
// do not over-write the file but share the stream pointer
|
||||||
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList.begin();
|
for(std::map<SystemFlags::DebugType,SystemFlags::SystemFlagsType>::iterator iterMap = SystemFlags::debugLogFileList->begin();
|
||||||
iterMap != SystemFlags::debugLogFileList.end(); iterMap++) {
|
iterMap != SystemFlags::debugLogFileList->end(); iterMap++) {
|
||||||
SystemFlags::SystemFlagsType ¤tDebugLog2 = iterMap->second;
|
SystemFlags::SystemFlagsType ¤tDebugLog2 = iterMap->second;
|
||||||
|
|
||||||
if( iterMap->first != type &&
|
if( iterMap->first != type &&
|
||||||
|
|
Loading…
Reference in New Issue