From: Alexander Steinhöfer Date: Wed, 6 Apr 2022 11:13:39 +0000 (+0200) Subject: Moved logfile path into WMLog class. X-Git-Tag: 1.9.9~11 X-Git-Url: https://repos.lx-s.de/gitweb/?a=commitdiff_plain;h=aa76181873f3c50e9831ed237d32944d5f599529;p=winmute.git Moved logfile path into WMLog class. --- diff --git a/WinMute/WMLog.cpp b/WinMute/WMLog.cpp index c0934ea..1a31ddc 100644 --- a/WinMute/WMLog.cpp +++ b/WinMute/WMLog.cpp @@ -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; diff --git a/WinMute/WMLog.h b/WinMute/WMLog.h index de4bcb3..20016b9 100644 --- a/WinMute/WMLog.h +++ b/WinMute/WMLog.h @@ -60,6 +60,7 @@ public: } void SetEnabled(bool enable); + std::string GetLogFilePath(); private: WMLog();