/////////////////////////////////////////////////////////////////////// // Name: AppendToLog() // Desc: add a line to global log file /////////////////////////////////////////////////////////////////////// void AppendToLog ( const char *dbgstring ) { String time( GetFormattedTime() ); debug_file << time << dbgstring << "\n"; // XXX: Flushing every time is brutally slow but helps // against losing log info if game suddenly crashes ! debug_file.flush(); }
std::string OldStyleLogProvider::FormatMessage(const char *message, const char *filename, int line, const char *function) { std::ostringstream val; val << std::string("[") << GetFormattedTime() << std::string("] [") << static_cast<unsigned long>(pthread_self()) << "/" << static_cast<int>(getpid()) << std::string("] [") << LocateSourceFileName(filename) << std::string(":") << line << std::string("] ") << function << std::string("(): ") << message; return val.str(); }
/////////////////////////////////////////////////////////////////////// // Name: OpenLog() // Desc: open global log file /////////////////////////////////////////////////////////////////////// bool OpenLog ( const char* filename ) { String time( GetFormattedTime() ); // open debug file debug_file.open ( filename, std::ios::out ); //ios::ate ); if ( ! debug_file.good() ) return false; debug_file << "<html><head><title>Savage Wheels Log File</title></head><body><h1>Savage Wheels V" << VER_MAJ << "." << VER_MIN << " - Log File</h1>"; debug_file << "<hr/><pre>"; debug_file << time << "Build: " << APP_NAME << " <br/>"; debug_file << time << "Copyright © 2003-2013 KenamicK Entertainment <br />"; debug_file << time << "Opened on: " << __DATE__ << "<br />"; debug_file << time << "Opened at: " << __TIME__ << "<br />"; debug_file << time << LOG_DASH << "<br />"; return true; }
void OldStyleLogProvider::Log(AbstractLogProvider::LogLevel level, const char *message, const char *fileName, int line, const char *function) const { try { const struct ColorMark& mark = consoleLevel.at(level); std::ostringstream val; val << mark.begin << std::string("[") << GetFormattedTime() << std::string("] [") << static_cast<unsigned long>(pthread_self()) << "/" << static_cast<int>(getpid()) << std::string("] [") << LocateSourceFileName(fileName) << std::string(":") << line << std::string("] ") << function << std::string("(): ") << message << mark.end; fprintf(stdout, "%s\n", val.str().c_str()); } catch (const std::out_of_range&) { fprintf(stdout, "Unsupported log level: %d\n", level); } }
// static void wxGenericProgressDialog::SetTimeLabel(unsigned long val, wxStaticText *label) { if ( label ) { wxString s; if (val != (unsigned long)-1) { s = GetFormattedTime(val); } else { s = _("Unknown"); } if ( s != label->GetLabel() ) label->SetLabel(s); } }