void AscEmuLog::ConsoleLogMajorError(std::string line1, std::string line2, std::string line3, std::string line4) { std::stringstream sstream; sstream << "*********************************************************************" << std::endl; sstream << "* MAJOR ERROR/WARNING " << std::endl; sstream << "* ******************* " << std::endl; sstream << "* " << line1 << std::endl; if (!line2.empty()) sstream << "* " << line2 << std::endl; if (!line3.empty()) sstream << "* " << line3 << std::endl; if (!line4.empty()) sstream << "* " << line4 << std::endl; sstream << "*********************************************************************" << std::endl; SetConsoleColor(CONSOLE_COLOR_RED); std::cout << sstream.str() << std::endl; SetConsoleColor(CONSOLE_COLOR_NORMAL); #if defined(linux) || defined(__linux) WriteFile(error_log_file, strdup(sstream.str().c_str())); #else WriteFile(error_log_file, _strdup(sstream.str().c_str())); #endif }
void Util::Print(LPWSTR s, ...) { va_list argList; va_start(argList, s); SetConsoleColor(WHITE); vwprintf(s, argList); SetConsoleColor(DEFAULT); va_end(argList); }
void Util::Notice(LPWSTR string, ...) { va_list argList; va_start(argList, string); SetConsoleColor(LIGHT_GREEN); wprintf(L"[+] "); vwprintf(string, argList); SetConsoleColor(DEFAULT); va_end(argList); }
void Util::Warn(LPWSTR string) { va_list argList; va_start(argList, string); SetConsoleColor(LIGHT_YELLOW); wprintf(L"[-] "); vwprintf(string, argList); SetConsoleColor(DEFAULT); va_end(argList); }
void Util::PrintLine() { WORD i; SetConsoleColor(CYAN); for(i = 0; i < 80; i++) // 25 rows, 80 columns for the old console display { wprintf(L"-"); } wprintf(L"\n"); SetConsoleColor(DEFAULT); }
void AscEmuLog::ConsoleLogError(bool file_only, const char* format, ...) { if (error_log_file == nullptr) return; char message_buffer[32768]; va_list ap; va_start(ap, format); vsnprintf(message_buffer, 32768, format, ap); va_end(ap); if (!file_only) { SetConsoleColor(CONSOLE_COLOR_RED); std::cerr << message_buffer << std::endl; SetConsoleColor(CONSOLE_COLOR_NORMAL); } WriteFile(error_log_file, message_buffer); }
void AscEmuLog::ConsoleLogDebugFlagFunction(bool file_only, LogFlags log_flags, const char* function, const char* format, ...) { if (aelog_file_log_level < LL_DEBUG || error_log_file == nullptr) return; char function_message[32768]; snprintf(function_message, 32768, "[DEBUG] %s %s", function, format); char message_buffer[32768]; va_list ap; va_start(ap, format); vsnprintf(message_buffer, 32768, function_message, ap); va_end(ap); if (!file_only) { SetConsoleColor(AELog::GetColorForDebugFlag(log_flags)); std::cout << message_buffer << std::endl; SetConsoleColor(CONSOLE_COLOR_NORMAL); } WriteFile(normal_log_file, message_buffer); }
void AscEmuLog::ConsoleLogDetailFunction(bool file_only, const char* function, const char* format, ...) { if (aelog_file_log_level < LL_DETAIL || normal_log_file == nullptr) return; char function_message[32768]; snprintf(function_message, 32768, "[DETAIL] %s %s", function, format); char message_buffer[32768]; va_list ap; va_start(ap, format); vsnprintf(message_buffer, 32768, function_message, ap); va_end(ap); if (!file_only) { SetConsoleColor(CONSOLE_COLOR_CYAN); std::cout << message_buffer << std::endl; SetConsoleColor(CONSOLE_COLOR_NORMAL); } WriteFile(normal_log_file, message_buffer); }
//消费者线程函数 unsigned int __stdcall ConsumerThreadFun(PVOID pM) { volatile bool flag = true; while (flag) { //等待缓冲区中有数据 WaitForSingleObject(g_hEventBufferFull, INFINITE); //互斥的访问缓冲区 EnterCriticalSection(&g_cs); SetConsoleColor(FOREGROUND_GREEN); printf(" 消费者从缓冲区中取数据%d\n", g_Buffer); SetConsoleColor(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); if (g_Buffer == END_PRODUCE_NUMBER) flag = false; LeaveCriticalSection(&g_cs); //通知缓冲区已为空 SetEvent(g_hEventBufferEmpty); Sleep(10); //some other work should to do } return 0; }
void Util::Error(DWORD error, LPWSTR string) { SetConsoleColor(LIGHT_RED); wprintf(L"[!] %s: %s\n", string, NetErrorToString(error)); SetConsoleColor(DEFAULT); }
void APIENTRY glDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) { #if SHOW_GL_WARNINGS char debSource[16], debType[20], debSev[5]; if(source == GL_DEBUG_SOURCE_API_ARB) strcpy(debSource, "OpenGL"); else if(source == GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB) strcpy(debSource, "Windows"); else if(source == GL_DEBUG_SOURCE_SHADER_COMPILER_ARB) strcpy(debSource, "Shader Compiler"); else if(source == GL_DEBUG_SOURCE_THIRD_PARTY_ARB) strcpy(debSource, "Third Party"); else if(source == GL_DEBUG_SOURCE_APPLICATION_ARB) strcpy(debSource, "Application"); else if(source == GL_DEBUG_SOURCE_OTHER_ARB) strcpy(debSource, "Other"); if(type == GL_DEBUG_TYPE_ERROR_ARB) strcpy(debType, "Error"); else if(type == GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) strcpy(debType, "Deprecated behavior"); else if(type == GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) strcpy(debType, "Undefined behavior"); else if(type == GL_DEBUG_TYPE_PORTABILITY_ARB) strcpy(debType, "Portability"); else if(type == GL_DEBUG_TYPE_PERFORMANCE_ARB) strcpy(debType, "Performance"); else if(type == GL_DEBUG_TYPE_OTHER_ARB) strcpy(debType, "Other"); if(severity == GL_DEBUG_SEVERITY_HIGH_ARB) { strcpy(debSev, "High"); SetConsoleColor(Red); printf("Source: %s\tType: %s\tID: %d\tSeverity: %s\nMessage: %s\n\n", debSource,debType,id,debSev,message); std::cin.ignore(); } else if(severity == GL_DEBUG_SEVERITY_MEDIUM_ARB) { strcpy(debSev, "Medium"); SetConsoleColor(Red); printf("Source: %s\tType: %s\tID: %d\tSeverity: %s\nMessage: %s\n\n", debSource,debType,id,debSev,message); std::cin.ignore(); } else if(severity == GL_DEBUG_SEVERITY_LOW_ARB) { static std::set<std::string> postedWarnings; strcpy(debSev, "Low"); std::string post = std::string("Source:") + debSource + "\nType:" + debType + "\nID:" + std::to_string(id) + "\nSeverity:" + debSev + "\nMessage:" + message + "\n"; if(postedWarnings.find(post) == postedWarnings.end()) { SetConsoleColor(Yellow); printf("Source: %s\tType: %s\tID: %d\tSeverity: %s\nMessage: %s\n\n", debSource,debType,id,debSev,message); SetConsoleColor(White); postedWarnings.insert(post); } } #endif }