17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-12 09:24:12 +01:00

fix(app): the log written to the end of the closing, each step of it with its time; the Discord thread idle outside the driver mode

The log service stopped with applicationQuitOrder, so whatever was logged while the simulator closed was lost; it now runs until StopLogService() and writes out what came before. The closing logs each of its steps with the time since it began, to tell where a closing that hangs stops. Outside the driver mode the Discord thread spun a core in its loop, it now sleeps a second between the checks.
This commit is contained in:
maj00r
2026-11-03 21:45:57 +01:00
parent 823807201c
commit b34238f33f
4 changed files with 30 additions and 3 deletions

View File

@@ -73,12 +73,21 @@ std::deque<std::string> ErrorStack;
// lock for log stacks
std::mutex logMutex;
// the log is written through the closing of the simulator, to the end
std::atomic<bool> logStop{false};
void StopLogService()
{
logStop = true;
}
void LogService()
{
while (!Global.applicationQuitOrder)
// one more pass after the stop, so what came just before it gets written too
for (bool last{false}; false == last;)
{
last = logStop;
{
// --- Obsługa InfoStack ---
while (!InfoStack.empty())

View File

@@ -23,7 +23,9 @@ enum class logtype : unsigned int {
traction = 1 << 9,
powergrid = 1 << 10,
};
// writes the log until StopLogService(), and all of it that came before
void LogService();
void StopLogService();
void WriteLog( const char *str, logtype const Type = logtype::generic, bool isError = false );
void Error( const std::string &asMessage, bool box = false );
void Error( const char* &asMessage, bool box = false );