Merge pull request #898 from Pax1601/release-candidate

Fixed error logger clearing file at all logs
This commit is contained in:
Pax1601 2024-07-22 18:04:18 +02:00 committed by GitHub
commit 97a11d6873
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -25,6 +25,7 @@ private:
mutex mutexLock;
void Clear();
void Open();
void Close();
};

View File

@ -19,6 +19,7 @@ Logger* Logger::GetLogger()
{
if (m_pThis == NULL) {
m_pThis = new Logger();
m_pThis->Clear();
}
return m_pThis;
}
@ -28,7 +29,7 @@ void Logger::setDirectory(string newDirPath)
m_dirPath = newDirPath;
}
void Logger::Open()
void Logger::Clear()
{
try {
m_Logfile.open((m_dirPath + m_sFileName).c_str(), ios::out | std::ios::trunc);
@ -39,6 +40,17 @@ void Logger::Open()
}
}
void Logger::Open()
{
try {
m_Logfile.open((m_dirPath + m_sFileName).c_str(), ios::out | std::ios::app);
}
catch (...) {
std::filesystem::path m_dirPath = std::filesystem::temp_directory_path();
m_Logfile.open((m_dirPath.string() + m_sFileName).c_str(), ios::out | std::ios::app);
}
}
void Logger::Close()
{
m_Logfile.close();