Minor update - Log window in Ui

This commit is contained in:
2025-01-17 17:57:58 +01:00
parent 4ae55e73b2
commit cb3f10b7d5
5 changed files with 154 additions and 25 deletions

View File

@@ -40,6 +40,12 @@ public:
Debug
};
struct LogEntry
{
std::string message;
LogLevel level;
};
Logger()
{
char* appdata = nullptr;
@@ -134,6 +140,8 @@ public:
<< "[" << fileName << ":" << lineNumber << "] "
<< message;
SendLogToUI(ss.str(), level);
std::ofstream file(m_logFilePath, std::ios::app);
if (file.is_open())
{
@@ -142,6 +150,16 @@ public:
}
}
void SendLogToUI(const std::string& message, LogLevel level)
{
m_logs.push_back({ message, level });
}
const std::vector<LogEntry>& GetLogs() const
{
return m_logs;
}
void ManageLogFiles(const std::string& directoryPath)
{
std::vector<std::filesystem::path> logFiles;
@@ -189,4 +207,5 @@ private:
std::string m_appdataPath;
std::string m_logFileName;
std::string m_logFilePath;
std::vector<LogEntry> m_logs;
};