diff --git a/EU07.cpp b/EU07.cpp index 2caf833a..29ed7d7b 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -39,7 +39,7 @@ void export_e3d_standalone(std::string in, std::string out, int flags, bool dyna #include #include #include - +#include #pragma comment(lib, "Dbghelp.lib") LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ExceptionInfo) @@ -78,6 +78,8 @@ int main(int argc, char *argv[]) #ifdef WITHDUMPGEN SetUnhandledExceptionFilter(CrashHandler); #endif + // init start timestamp + Global.startTimestamp = std::chrono::steady_clock::now(); // quick short-circuit for standalone e3d export if (argc == 6 && std::string(argv[1]) == "-e3d") { diff --git a/Globals.h b/Globals.h index e49ee71f..719f4a03 100644 --- a/Globals.h +++ b/Globals.h @@ -30,6 +30,8 @@ struct global_settings { // data items // TODO: take these out of the settings + std::chrono::steady_clock::time_point startTimestamp; + /// /// Mapa z watkami w formacie /// diff --git a/Logs.cpp b/Logs.cpp index 61dd173e..41bfac1e 100644 --- a/Logs.cpp +++ b/Logs.cpp @@ -152,8 +152,23 @@ void WriteLog(const char *str, logtype const Type, bool isError) return; if (TestFlag(Global.DisabledLogTypes, static_cast(Type))) return; + + // time calculation + auto now = std::chrono::steady_clock::now(); + auto elapsed = now - Global.startTimestamp; + double seconds = std::chrono::duration_cast>(elapsed).count(); + + // time format + std::ostringstream oss; + oss << "[ " << std::fixed << std::setprecision(3) << seconds << " ] "; + + // wyrownanie do np. 10 znaków długości + dwie tabulacje + std::ostringstream final; + final << std::setw(10) << oss.str() << "\t\t" << str; + + logMutex.lock(); - InfoStack.emplace_back(str, isError); + InfoStack.emplace_back(final.str(), isError); logMutex.unlock(); } @@ -163,8 +178,22 @@ void ErrorLog(const char *str, logtype const Type) return; if (TestFlag(Global.DisabledLogTypes, static_cast(Type))) return; + + // time calculation + auto now = std::chrono::steady_clock::now(); + auto elapsed = now - Global.startTimestamp; + double seconds = std::chrono::duration_cast>(elapsed).count(); + + // time format + std::ostringstream oss; + oss << "[ " << std::fixed << std::setprecision(3) << seconds << " ] "; + + // wyrownanie do np. 10 znaków długości + dwie tabulacje + std::ostringstream final; + final << std::setw(10) << oss.str() << "\t\t" << str; + logMutex.lock(); - ErrorStack.emplace_back(str); + ErrorStack.emplace_back(final.str()); logMutex.unlock(); } diff --git a/application.cpp b/application.cpp index a0525c1e..c192cf83 100644 --- a/application.cpp +++ b/application.cpp @@ -270,7 +270,6 @@ int eu07_application::init( int Argc, char *Argv[] ) { int result { 0 }; - init_debug(); init_files(); if( ( result = init_settings( Argc, Argv ) ) != 0 ) {