Engine exited successfully on " << currentDate; *m_MainLog << " at " << currentTime << buffer << "
\n"; *m_MainLog << html_footer; *m_InterestingLog << "Engine exited successfully on " << currentDate; *m_InterestingLog << " at " << currentTime << buffer << "
\n"; *m_InterestingLog << html_footer; if (m_OwnsStreams) { delete m_InterestingLog; delete m_MainLog; } } void CLogger::WriteMessage(const char *message) { ++m_NumberOfMessages; *m_MainLog << "" << message << "
\n"; m_MainLog->flush(); } void CLogger::WriteError(const char *message) { ++m_NumberOfErrors; if (m_UseDebugPrintf) debug_printf("ERROR: %s\n", message); if (g_Console) g_Console->InsertMessage(L"ERROR: %hs", message); *m_InterestingLog << "ERROR: "<< message << "
\n"; m_InterestingLog->flush(); *m_MainLog << "ERROR: "<< message << "
\n"; m_MainLog->flush(); } void CLogger::WriteWarning(const char *message) { ++m_NumberOfWarnings; if (g_Console) g_Console->InsertMessage(L"WARNING: %hs", message); *m_InterestingLog << "WARNING: "<< message << "
\n"; m_InterestingLog->flush(); *m_MainLog << "WARNING: "<< message << "
\n"; m_MainLog->flush(); } // Sends the message to the appropriate piece of code // -- This function has not been removed because the build would break. void CLogger::LogUsingMethod(ELogMethod method, const char* message) { if(method == Normal) WriteMessage(message); else if(method == Error) WriteError(message); else if(method == Warning) WriteWarning(message); else WriteMessage(message); } // -- This function has not been removed because the build would break. void CLogger::Log(ELogMethod method, const char* category, const char *fmt, ...) { va_list argp; char buffer[512]; va_start(argp, fmt); if (sys_vsnprintf(buffer, sizeof(buffer), fmt, argp) == -1) { // Buffer too small - ensure the string is nicely terminated strcpy(buffer+sizeof(buffer)-4, "..."); // safe } va_end(argp); LogUsingMethod(method, buffer); } // -- This function has not been removed because the build would break. void CLogger::LogOnce(ELogMethod method, const char* category, const char *fmt, ...) { va_list argp; char buffer[512]; va_start(argp, fmt); if (sys_vsnprintf(buffer, sizeof(buffer), fmt, argp) == -1) { // Buffer too small - ensure the string is nicely terminated strcpy(buffer+sizeof(buffer)-4, "..."); // safe } va_end(argp); std::string message (buffer); // If this message has already been logged, ignore it if (m_LoggedOnce.find(message) != m_LoggedOnce.end()) return; // If not, mark it as having been logged and then log it m_LoggedOnce.insert(message); LogUsingMethod(method, buffer); } void CLogger::LogMessage(const char *fmt, ...) { va_list argp; char buffer[512]; va_start(argp, fmt); if (sys_vsnprintf(buffer, sizeof(buffer), fmt, argp) == -1) { // Buffer too small - ensure the string is nicely terminated strcpy(buffer+sizeof(buffer)-4, "..."); // safe } va_end(argp); WriteMessage(buffer); } void CLogger::LogWarning(const char *fmt, ...) { va_list argp; char buffer[512]; va_start(argp, fmt); if (sys_vsnprintf(buffer, sizeof(buffer), fmt, argp) == -1) { // Buffer too small - ensure the string is nicely terminated strcpy(buffer+sizeof(buffer)-4, "..."); // safe } va_end(argp); WriteWarning(buffer); } void CLogger::LogError(const char *fmt, ...) { va_list argp; char buffer[512]; va_start(argp, fmt); if (sys_vsnprintf(buffer, sizeof(buffer), fmt, argp) == -1) { // Buffer too small - ensure the string is nicely terminated strcpy(buffer+sizeof(buffer)-4, "..."); // safe } va_end(argp); WriteError(buffer); } TestLogger::TestLogger() { m_OldLogger = g_Logger; g_Logger = new CLogger(&m_Stream, &blackHoleStream, false, false); } TestLogger::~TestLogger() { delete g_Logger; g_Logger = m_OldLogger; } std::string TestLogger::GetOutput() { return m_Stream.str(); }