]> repos.lx-s.de Git - winmute.git/commitdiff
Moved logfile path into WMLog class.
authorAlexander Steinhöfer <alexander@steinhoefer.net>
Wed, 6 Apr 2022 11:13:39 +0000 (13:13 +0200)
committerAlexander Steinhöfer <alexander@steinhoefer.net>
Wed, 6 Apr 2022 11:13:39 +0000 (13:13 +0200)
WinMute/WMLog.cpp
WinMute/WMLog.h

index c0934ea587d321a84f15532396c29b00e861aacb..1a31ddcbec3a109f2574e7e71339d74d8c3b413b 100644 (file)
@@ -34,14 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "common.h"
 
 #ifdef UNICODE
-static bool OpenLogFile(std::wofstream& logFile)
+static bool OpenLogFile(const std::string& filePath, std::wofstream& logFile)
 #else
-static bool OpenLogFile(std::ofstream& logFile)
+static bool OpenLogFile(const std::string& filePath, std::ofstream& logFile)
 #endif
 {
-   auto path = std::filesystem::temp_directory_path();
-   path /= L"WinMute.log";
-   logFile.open(path.string(), std::ios::out | std::ios::app | std::ios::binary);
+   logFile.open(filePath, std::ios::out | std::ios::app | std::ios::binary);
    return logFile.is_open();
 }
 
@@ -54,7 +52,7 @@ WMLog& WMLog::GetInstance()
 WMLog::WMLog() :
    initialized_(false)
 {
-   if (OpenLogFile(logFile_)) {
+   if (OpenLogFile(GetLogFilePath(), logFile_)) {
       initialized_ = true;
    }
 }
@@ -66,6 +64,13 @@ WMLog::~WMLog()
    }
 }
 
+std::string WMLog::GetLogFilePath()
+{
+   auto path = std::filesystem::temp_directory_path();
+   path /= _T("WinMute.log");
+   return path.string();
+}
+
 void WMLog::SetEnabled(bool enable)
 {
    enabled_ = enable;
index de4bcb3a2e76c42982c0f2ab1ca59c56d6b8b8a7..20016b9895633d32ba63419b34013551362c61d2 100644 (file)
@@ -60,6 +60,7 @@ public:
    }
 
    void SetEnabled(bool enable);
+   std::string GetLogFilePath();
 
 private:
    WMLog();