CppLogger::CppLogger() { //start set default values isDebugLog = false; isErrorLog = false; debugFileSizeMB = 10; errorFileSizeMB = 10; directory = "logs"; filename = "log"; filesNum = 2; //end set default values //try to get settings from file parseConfFile(); struct stat st; //check if directory exist if (stat(directory.c_str(), &st) != 0) { #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) std::string command = "mkdir "; command+= directory; system(command.c_str()); #else //if not exist create directory mkdir(directory.c_str(), 0777); #endif } fileDebug.open((directory + '/' + filename + "_debug.txt").c_str(), std::ios::out | std::ios::in | std::ios::app); fileError.open((directory + '/' + filename + "_error.txt").c_str(), std::ios::out | std::ios::in | std::ios::app); }
int demoParseConfFile(const char* path, bool isDebug) { std::map<std::string, std::string> confMap; const char* confPath = (path) ? path : #if (defined __linux__ || defined __unix__) "./config/ogl3.conf"; #else "../config/ogl3.conf"; #endif parseConfFile(confPath, confMap); std::string objPath0 = confMap["objPath0"], shaderFrag0 = confMap["shaderFrag0"], shaderVert0 = confMap["shaderVert0"]; int windowWid, windowHgt; float clearColor[4], lightPosition[3], rotAngle; // confScanNums(str, numCt, isFloat, numArr); confScanNums(confMap["clearColor"], 4, true, clearColor); confScanNums(confMap["lightPosition"], 4, true, lightPosition); confScanNums(confMap["rotAngle"], 1, true, &rotAngle); confScanNums(confMap["windowWid"],1, false, &windowWid); confScanNums(confMap["windowHgt"], 1, false, &windowHgt); fprintf(stderr, "----- Display Entire Config Map -----\n\n"); if (isDebug) displayConfMap(confMap); fprintf(stderr, "-------------------------------------\n\n"); printf("clearColor(%f, %f, %f, %f)\n", clearColor[0], clearColor[1], clearColor[2], clearColor[3]); printf("windowWid(%d)\n", windowWid); printf("shaderVert0(%s)\n", shaderVert0.c_str()); printf("\nTo exit, hit any key\n"); char c; int res = scanf("%c", &c); res += 1; exit(EXIT_SUCCESS); } // end demoParseConfFile