diff --git a/es-core/src/Log.cpp b/es-core/src/Log.cpp index b3a4dd149..fe0ae4eff 100644 --- a/es-core/src/Log.cpp +++ b/es-core/src/Log.cpp @@ -22,16 +22,12 @@ void Log::setReportingLevel(LogLevel level) sReportingLevel = level; } -std::string Log::getLogPath() -{ - return Utils::FileSystem::getHomePath() + "/.emulationstation/es_log.txt"; -} - void Log::init() { - Utils::FileSystem::removeFile(getLogPath() + ".bak"); + sLogPath = Utils::FileSystem::getAppDataDirectory().append("es_log.txt"); + Utils::FileSystem::removeFile(sLogPath.string() + ".bak"); // Rename the previous log file. - Utils::FileSystem::renameFile(getLogPath(), getLogPath() + ".bak", true); + Utils::FileSystem::renameFile(sLogPath.string(), sLogPath.string() + ".bak", true); return; } @@ -39,9 +35,9 @@ void Log::open() { std::unique_lock lock {sLogMutex}; #if defined(_WIN64) - sFile.open(Utils::String::stringToWideString(getLogPath()).c_str()); + sFile.open(Utils::String::stringToWideString(sLogPath.string()).c_str()); #else - sFile.open(getLogPath().c_str()); + sFile.open(sLogPath.string().c_str()); #endif } diff --git a/es-core/src/Log.h b/es-core/src/Log.h index 41e1f1f1c..487eb404c 100644 --- a/es-core/src/Log.h +++ b/es-core/src/Log.h @@ -47,7 +47,6 @@ public: static void setReportingLevel(LogLevel level); // These functions are not thread safe. - static std::string getLogPath(); static void init(); static void open(); @@ -66,6 +65,7 @@ private: static inline std::ofstream sFile; static inline LogLevel sReportingLevel = LogInfo; static inline std::mutex sLogMutex; + static inline std::filesystem::path sLogPath; LogLevel mMessageLevel; };