- added new --verbose commandline option
This commit is contained in:
parent
8534fa59a9
commit
69e0130296
|
@ -119,7 +119,7 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(fileName.second != "" && fileExists(fileName.second) == false) {
|
if(fileName.second != "" && fileExists(fileName.second) == false) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] attempting to auto-create cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] attempting to auto-create cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str());
|
||||||
|
|
||||||
std::ofstream userFile;
|
std::ofstream userFile;
|
||||||
userFile.open(fileName.second.c_str(), ios_base::out | ios_base::trunc);
|
userFile.open(fileName.second.c_str(), ios_base::out | ios_base::trunc);
|
||||||
|
@ -136,15 +136,15 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
|
||||||
|
|
||||||
Config &Config::getInstance(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist) {
|
Config &Config::getInstance(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist) {
|
||||||
if(configList.find(type.first) == configList.end()) {
|
if(configList.find(type.first) == configList.end()) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
Config config(type, file, fileMustExist);
|
Config config(type, file, fileMustExist);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
configList.insert(map<ConfigType,Config>::value_type(type.first,config));
|
configList.insert(map<ConfigType,Config>::value_type(type.first,config));
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
return configList.find(type.first)->second;
|
return configList.find(type.first)->second;
|
||||||
|
@ -159,17 +159,17 @@ void Config::CopyAll(Config *src, Config *dest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::reload() {
|
void Config::reload() {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame);
|
std::pair<ConfigType,ConfigType> type = std::make_pair(cfgMainGame,cfgUserGame);
|
||||||
Config newconfig(type, std::make_pair(glest_ini_filename,glestuser_ini_filename), std::make_pair(true,false));
|
Config newconfig(type, std::make_pair(glest_ini_filename,glestuser_ini_filename), std::make_pair(true,false));
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
Config &oldconfig = configList.find(type.first)->second;
|
Config &oldconfig = configList.find(type.first)->second;
|
||||||
CopyAll(&newconfig, &oldconfig);
|
CopyAll(&newconfig, &oldconfig);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::save(const string &path){
|
void Config::save(const string &path){
|
||||||
|
|
|
@ -85,7 +85,8 @@ const char *GAME_ARGS[] = {
|
||||||
"--validate-factions",
|
"--validate-factions",
|
||||||
"--data-path",
|
"--data-path",
|
||||||
"--ini-path",
|
"--ini-path",
|
||||||
"--log-path"
|
"--log-path",
|
||||||
|
"--verbose"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,7 +104,8 @@ enum GAME_ARG_TYPE {
|
||||||
GAME_ARG_VALIDATE_FACTIONS,
|
GAME_ARG_VALIDATE_FACTIONS,
|
||||||
GAME_ARG_DATA_PATH,
|
GAME_ARG_DATA_PATH,
|
||||||
GAME_ARG_INI_PATH,
|
GAME_ARG_INI_PATH,
|
||||||
GAME_ARG_LOG_PATH
|
GAME_ARG_LOG_PATH,
|
||||||
|
GAME_ARG_VERBOSE_MODE
|
||||||
};
|
};
|
||||||
|
|
||||||
string runtimeErrorMsg = "";
|
string runtimeErrorMsg = "";
|
||||||
|
@ -615,6 +617,8 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
||||||
printf("\n \t\texample: %s %s=~/game_config/",argv0,GAME_ARGS[GAME_ARG_INI_PATH]);
|
printf("\n \t\texample: %s %s=~/game_config/",argv0,GAME_ARGS[GAME_ARG_INI_PATH]);
|
||||||
printf("\n%s=x\t\t\tSets the game logs path to x",GAME_ARGS[GAME_ARG_LOG_PATH]);
|
printf("\n%s=x\t\t\tSets the game logs path to x",GAME_ARGS[GAME_ARG_LOG_PATH]);
|
||||||
printf("\n \t\texample: %s %s=~/game_logs/",argv0,GAME_ARGS[GAME_ARG_LOG_PATH]);
|
printf("\n \t\texample: %s %s=~/game_logs/",argv0,GAME_ARGS[GAME_ARG_LOG_PATH]);
|
||||||
|
printf("\n%s\t\t\tdisplays verbose information in the console.",GAME_ARGS[GAME_ARG_VERBOSE_MODE]);
|
||||||
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,6 +642,11 @@ int glestMain(int argc, char** argv) {
|
||||||
printParameterHelp(argv[0],foundInvalidArgs);
|
printParameterHelp(argv[0],foundInvalidArgs);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::VERBOSE_MODE_ENABLED = false;
|
||||||
|
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERBOSE_MODE]) == true) {
|
||||||
|
SystemFlags::VERBOSE_MODE_ENABLED = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool haveSpecialOutputCommandLineOption = false;
|
bool haveSpecialOutputCommandLineOption = false;
|
||||||
|
|
||||||
|
@ -711,7 +720,7 @@ int glestMain(int argc, char** argv) {
|
||||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||||
string customPathValue = paramPartTokens[1];
|
string customPathValue = paramPartTokens[1];
|
||||||
pathCache[GameConstants::path_data_CacheLookupKey]=customPathValue;
|
pathCache[GameConstants::path_data_CacheLookupKey]=customPathValue;
|
||||||
printf("Using custom data path [%s]\n",customPathValue.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using custom data path [%s]\n",customPathValue.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -734,7 +743,7 @@ int glestMain(int argc, char** argv) {
|
||||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||||
string customPathValue = paramPartTokens[1];
|
string customPathValue = paramPartTokens[1];
|
||||||
pathCache[GameConstants::path_ini_CacheLookupKey]=customPathValue;
|
pathCache[GameConstants::path_ini_CacheLookupKey]=customPathValue;
|
||||||
printf("Using custom ini path [%s]\n",customPathValue.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using custom ini path [%s]\n",customPathValue.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -757,7 +766,7 @@ int glestMain(int argc, char** argv) {
|
||||||
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
|
||||||
string customPathValue = paramPartTokens[1];
|
string customPathValue = paramPartTokens[1];
|
||||||
pathCache[GameConstants::path_logs_CacheLookupKey]=customPathValue;
|
pathCache[GameConstants::path_logs_CacheLookupKey]=customPathValue;
|
||||||
printf("Using custom logs path [%s]\n",customPathValue.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using custom logs path [%s]\n",customPathValue.c_str());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -848,7 +857,7 @@ int glestMain(int argc, char** argv) {
|
||||||
SystemFlags::getSystemSettingType(SystemFlags::debugError).debugLogFileName = debugErrorLogFile;
|
SystemFlags::getSystemSettingType(SystemFlags::debugError).debugLogFileName = debugErrorLogFile;
|
||||||
|
|
||||||
if(haveSpecialOutputCommandLineOption == false) {
|
if(haveSpecialOutputCommandLineOption == false) {
|
||||||
printf("Startup settings are: debugSystem [%d], debugNetwork [%d], debugPerformance [%d], debugWorldSynch [%d], debugUnitCommands[%d], debugPathFinder[%d], debugLUA [%d], debugError [%d]\n",
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Startup settings are: debugSystem [%d], debugNetwork [%d], debugPerformance [%d], debugWorldSynch [%d], debugUnitCommands[%d], debugPathFinder[%d], debugLUA [%d], debugError [%d]\n",
|
||||||
SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled,
|
SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled,
|
||||||
SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled,
|
SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled,
|
||||||
SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled,
|
SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled,
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
DebugType debugType;
|
DebugType debugType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SystemFlagsType() {
|
SystemFlagsType() {
|
||||||
this->debugType = debugSystem;
|
this->debugType = debugSystem;
|
||||||
|
@ -117,6 +117,7 @@ public:
|
||||||
|
|
||||||
static CURL *curl_handle;
|
static CURL *curl_handle;
|
||||||
static int DEFAULT_HTTP_TIMEOUT;
|
static int DEFAULT_HTTP_TIMEOUT;
|
||||||
|
static bool VERBOSE_MODE_ENABLED;
|
||||||
|
|
||||||
SystemFlags();
|
SystemFlags();
|
||||||
~SystemFlags();
|
~SystemFlags();
|
||||||
|
|
|
@ -45,6 +45,7 @@ string SystemFlags::lockfilename = "";
|
||||||
bool SystemFlags::haveSpecialOutputCommandLineOption = false;
|
bool SystemFlags::haveSpecialOutputCommandLineOption = false;
|
||||||
CURL *SystemFlags::curl_handle = NULL;
|
CURL *SystemFlags::curl_handle = NULL;
|
||||||
int SystemFlags::DEFAULT_HTTP_TIMEOUT = 10;
|
int SystemFlags::DEFAULT_HTTP_TIMEOUT = 10;
|
||||||
|
bool SystemFlags::VERBOSE_MODE_ENABLED = false;
|
||||||
//
|
//
|
||||||
|
|
||||||
static void *myrealloc(void *ptr, size_t size)
|
static void *myrealloc(void *ptr, size_t size)
|
||||||
|
@ -217,7 +218,7 @@ SystemFlags::~SystemFlags() {
|
||||||
void SystemFlags::Close() {
|
void SystemFlags::Close() {
|
||||||
if(SystemFlags::debugLogFileList.size() > 0) {
|
if(SystemFlags::debugLogFileList.size() > 0) {
|
||||||
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
||||||
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();
|
||||||
|
@ -243,7 +244,7 @@ void SystemFlags::Close() {
|
||||||
|
|
||||||
if(SystemFlags::debugLogFileList.size() > 0) {
|
if(SystemFlags::debugLogFileList.size() > 0) {
|
||||||
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
||||||
printf("END Closing logfiles\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("END Closing logfiles\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,7 +329,7 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
debugLog += intToStr(idx);
|
debugLog += intToStr(idx);
|
||||||
|
|
||||||
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
||||||
printf("Opening additional logfile [%s]\n",debugLog.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Opening additional logfile [%s]\n",debugLog.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +337,7 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
debugLog += intToStr(SystemFlags::lockFileCountIndex);
|
debugLog += intToStr(SystemFlags::lockFileCountIndex);
|
||||||
|
|
||||||
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
||||||
printf("Opening additional logfile [%s]\n",debugLog.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Opening additional logfile [%s]\n",debugLog.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +349,7 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
if(SystemFlags::haveSpecialOutputCommandLineOption == false) {
|
||||||
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(SystemFlags::VERBOSE_MODE_ENABLED) 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) {
|
if(currentDebugLog.fileStream->is_open() == true) {
|
||||||
|
@ -361,10 +362,6 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("Logfile is open [%s]\n",SystemFlags::debugLogFile);
|
|
||||||
|
|
||||||
//printf("writing to logfile [%s]\n",szBuf);
|
|
||||||
|
|
||||||
assert(currentDebugLog.fileStream != NULL);
|
assert(currentDebugLog.fileStream != NULL);
|
||||||
|
|
||||||
if(currentDebugLog.fileStream->is_open() == true) {
|
if(currentDebugLog.fileStream->is_open() == true) {
|
||||||
|
@ -391,6 +388,7 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) {
|
||||||
(currentDebugLog.debugLogFileName != "" &&
|
(currentDebugLog.debugLogFileName != "" &&
|
||||||
(currentDebugLog.fileStream == NULL ||
|
(currentDebugLog.fileStream == NULL ||
|
||||||
currentDebugLog.fileStream->is_open() == false))) {
|
currentDebugLog.fileStream->is_open() == false))) {
|
||||||
|
|
||||||
if (type != debugPathFinder && type != debugError) {
|
if (type != debugPathFinder && type != debugError) {
|
||||||
printf("[%s] %s", szBuf2, szBuf);
|
printf("[%s] %s", szBuf2, szBuf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user