From aa76181873f3c50e9831ed237d32944d5f599529 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexander=20Steinh=C3=B6fer?= Date: Wed, 6 Apr 2022 13:13:39 +0200 Subject: [PATCH] Moved logfile path into WMLog class. --- WinMute/WMLog.cpp | 17 +++++++++++------ WinMute/WMLog.h | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) 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(); -- 2.43.0