- added some additional safety around the logger in case we have problems opening files on the filesystem

This commit is contained in:
Mark Vejvoda 2010-10-15 16:22:35 +00:00
parent 427f505c4c
commit 1353f61069

View File

@ -342,9 +342,10 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
}
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
printf("Opening logfile [%s] type = %d, currentDebugLog.fileStreamOwner = %d\n",debugLog.c_str(),type, currentDebugLog.fileStreamOwner);
printf("Opening logfile [%s] type = %d, currentDebugLog.fileStreamOwner = %d, file stream open = %d\n",debugLog.c_str(),type, currentDebugLog.fileStreamOwner,currentDebugLog.fileStream->is_open());
}
if(currentDebugLog.fileStream->is_open() == true) {
MutexSafeWrapper safeMutex(currentDebugLog.mutex);
(*currentDebugLog.fileStream) << "Starting Mega-Glest logging for type: " << type << "\n";
@ -352,6 +353,7 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
safeMutex.ReleaseLock();
}
}
//printf("Logfile is open [%s]\n",SystemFlags::debugLogFile);
@ -359,6 +361,7 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
assert(currentDebugLog.fileStream != NULL);
if(currentDebugLog.fileStream->is_open() == true) {
MutexSafeWrapper safeMutex(currentDebugLog.mutex);
if (type != debugPathFinder && type != debugError) {
@ -374,8 +377,13 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
safeMutex.ReleaseLock();
}
}
// output to console
else {
if( currentDebugLog.debugLogFileName == "" ||
(currentDebugLog.debugLogFileName != "" &&
(currentDebugLog.fileStream == NULL ||
currentDebugLog.fileStream->is_open() == false))) {
if (type != debugPathFinder && type != debugError) {
printf("[%s] %s", szBuf2, szBuf);
}