mirror of
				https://github.com/RetroDECK/ES-DE.git
				synced 2025-04-10 19:15:13 +00:00 
			
		
		
		
	Changed Log to set the log path once on application startup
This commit is contained in:
		
							parent
							
								
									56ccba81d1
								
							
						
					
					
						commit
						03e9035b7e
					
				|  | @ -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<std::mutex> 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 | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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; | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Leon Styhre
						Leon Styhre