#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();
}
WMLog::WMLog() :
initialized_(false)
{
- if (OpenLogFile(logFile_)) {
+ if (OpenLogFile(GetLogFilePath(), logFile_)) {
initialized_ = true;
}
}
}
}
+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;