mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Add log timer
This commit is contained in:
4
EU07.cpp
4
EU07.cpp
@@ -39,7 +39,7 @@ void export_e3d_standalone(std::string in, std::string out, int flags, bool dyna
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <Globals.h>
|
||||||
#pragma comment(lib, "Dbghelp.lib")
|
#pragma comment(lib, "Dbghelp.lib")
|
||||||
|
|
||||||
LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ExceptionInfo)
|
LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ExceptionInfo)
|
||||||
@@ -78,6 +78,8 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef WITHDUMPGEN
|
#ifdef WITHDUMPGEN
|
||||||
SetUnhandledExceptionFilter(CrashHandler);
|
SetUnhandledExceptionFilter(CrashHandler);
|
||||||
#endif
|
#endif
|
||||||
|
// init start timestamp
|
||||||
|
Global.startTimestamp = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
// quick short-circuit for standalone e3d export
|
// quick short-circuit for standalone e3d export
|
||||||
if (argc == 6 && std::string(argv[1]) == "-e3d") {
|
if (argc == 6 && std::string(argv[1]) == "-e3d") {
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ struct global_settings {
|
|||||||
// data items
|
// data items
|
||||||
// TODO: take these out of the settings
|
// TODO: take these out of the settings
|
||||||
|
|
||||||
|
std::chrono::steady_clock::time_point startTimestamp;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Mapa z watkami w formacie <std::string nazwa, std::thread watek>
|
/// Mapa z watkami w formacie <std::string nazwa, std::thread watek>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
33
Logs.cpp
33
Logs.cpp
@@ -152,8 +152,23 @@ void WriteLog(const char *str, logtype const Type, bool isError)
|
|||||||
return;
|
return;
|
||||||
if (TestFlag(Global.DisabledLogTypes, static_cast<unsigned int>(Type)))
|
if (TestFlag(Global.DisabledLogTypes, static_cast<unsigned int>(Type)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// time calculation
|
||||||
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
auto elapsed = now - Global.startTimestamp;
|
||||||
|
double seconds = std::chrono::duration_cast<std::chrono::duration<double>>(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();
|
logMutex.lock();
|
||||||
InfoStack.emplace_back(str, isError);
|
InfoStack.emplace_back(final.str(), isError);
|
||||||
logMutex.unlock();
|
logMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,8 +178,22 @@ void ErrorLog(const char *str, logtype const Type)
|
|||||||
return;
|
return;
|
||||||
if (TestFlag(Global.DisabledLogTypes, static_cast<unsigned int>(Type)))
|
if (TestFlag(Global.DisabledLogTypes, static_cast<unsigned int>(Type)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// time calculation
|
||||||
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
auto elapsed = now - Global.startTimestamp;
|
||||||
|
double seconds = std::chrono::duration_cast<std::chrono::duration<double>>(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();
|
logMutex.lock();
|
||||||
ErrorStack.emplace_back(str);
|
ErrorStack.emplace_back(final.str());
|
||||||
logMutex.unlock();
|
logMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,6 @@ int
|
|||||||
eu07_application::init( int Argc, char *Argv[] ) {
|
eu07_application::init( int Argc, char *Argv[] ) {
|
||||||
|
|
||||||
int result { 0 };
|
int result { 0 };
|
||||||
|
|
||||||
init_debug();
|
init_debug();
|
||||||
init_files();
|
init_files();
|
||||||
if( ( result = init_settings( Argc, Argv ) ) != 0 ) {
|
if( ( result = init_settings( Argc, Argv ) ) != 0 ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user