diff --git a/Library/CommandHandler.cpp b/Library/CommandHandler.cpp index 581a3d01..08393804 100644 --- a/Library/CommandHandler.cpp +++ b/Library/CommandHandler.cpp @@ -916,7 +916,7 @@ void CommandHandler::DoLogBang(std::vector& args, MeterWindow* ski } } - Logger::GetInstance().Log(level, args[0].c_str()); + GetLogger().Log(level, args[0].c_str()); } } diff --git a/Library/DialogAbout.cpp b/Library/DialogAbout.cpp index 5a5f22b6..6ad72cfc 100644 --- a/Library/DialogAbout.cpp +++ b/Library/DialogAbout.cpp @@ -407,7 +407,7 @@ void DialogAbout::TabLog::Initialize() ListView_InsertColumn(item, 2, &lvc); // Add stored entires - for (const auto& entry : Logger::GetInstance().GetEntries()) + for (const auto& entry : GetLogger().GetEntries()) { AddItem(entry.level, entry.timestamp.c_str(), entry.message.c_str()); } diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index 82c66ca4..b9a42ab1 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -1898,10 +1898,10 @@ void DialogManage::TabSettings::Initialize() Button_SetCheck(GetControl(Id_CheckForUpdatesCheckBox), !GetRainmeter().GetDisableVersionCheck()); Button_SetCheck(GetControl(Id_LockSkinsCheckBox), GetRainmeter().GetDisableDragging()); - Button_SetCheck(GetControl(Id_LogToFileCheckBox), Logger::GetInstance().IsLogToFile()); + Button_SetCheck(GetControl(Id_LogToFileCheckBox), GetLogger().IsLogToFile()); Button_SetCheck(GetControl(Id_VerboseLoggingCheckbox), GetRainmeter().GetDebug()); - BOOL isLogFile = (_waccess(Logger::GetInstance().GetLogFilePath().c_str(), 0) != -1); + BOOL isLogFile = (_waccess(GetLogger().GetLogFilePath().c_str(), 0) != -1); EnableWindow(GetControl(Id_ShowLogFileButton), isLogFile); EnableWindow(GetControl(Id_DeleteLogFileButton), isLogFile); @@ -1996,8 +1996,8 @@ INT_PTR DialogManage::TabSettings::OnCommand(WPARAM wParam, LPARAM lParam) break; case Id_DeleteLogFileButton: - Logger::GetInstance().DeleteLogFile(); - if (_waccess(Logger::GetInstance().GetLogFilePath().c_str(), 0) == -1) + GetLogger().DeleteLogFile(); + if (_waccess(GetLogger().GetLogFilePath().c_str(), 0) == -1) { Button_SetCheck(GetControl(Id_LogToFileCheckBox), BST_UNCHECKED); EnableWindow(GetControl(Id_ShowLogFileButton), FALSE); @@ -2006,14 +2006,14 @@ INT_PTR DialogManage::TabSettings::OnCommand(WPARAM wParam, LPARAM lParam) break; case Id_LogToFileCheckBox: - if (Logger::GetInstance().IsLogToFile()) + if (GetLogger().IsLogToFile()) { - Logger::GetInstance().StopLogFile(); + GetLogger().StopLogFile(); } else { - Logger::GetInstance().StartLogFile(); - if (_waccess(Logger::GetInstance().GetLogFilePath().c_str(), 0) != -1) + GetLogger().StartLogFile(); + if (_waccess(GetLogger().GetLogFilePath().c_str(), 0) != -1) { EnableWindow(GetControl(Id_ShowLogFileButton), TRUE); EnableWindow(GetControl(Id_DeleteLogFileButton), TRUE); diff --git a/Library/Export.cpp b/Library/Export.cpp index d96fa292..18ee394e 100644 --- a/Library/Export.cpp +++ b/Library/Export.cpp @@ -112,7 +112,7 @@ BOOL LSLog(int nLevel, LPCWSTR unused, LPCWSTR pszMessage) // Ignore Level::Debug messages from plugins unless in debug mode if (nLevel != (int)Logger::Level::Debug || GetRainmeter().GetDebug()) { - Logger::GetInstance().Log((Logger::Level)nLevel, pszMessage); + GetLogger().Log((Logger::Level)nLevel, pszMessage); } return TRUE; diff --git a/Library/Logger.h b/Library/Logger.h index e6a42ff2..fbe59b11 100644 --- a/Library/Logger.h +++ b/Library/Logger.h @@ -79,10 +79,12 @@ private: }; // Convenience functions. +inline Logger& GetLogger() { return Logger::GetInstance(); } + #define RM_LOGGER_DEFINE_LOG_FUNCTION(name) \ inline void Log ## name(const WCHAR* msg) \ { \ - Logger::GetInstance().Log(Logger::Level::name, msg); \ + GetLogger().Log(Logger::Level::name, msg); \ } \ /* \ template \ @@ -99,7 +101,7 @@ RM_LOGGER_DEFINE_LOG_FUNCTION(Debug) // FIXME: Temporary solution until VS support variadic templates. #define RM_LOGGER_LOGF_HELPER(name, format, ...) \ - Logger::GetInstance().LogF(Logger::Level::name, format, __VA_ARGS__) + GetLogger().LogF(Logger::Level::name, format, __VA_ARGS__) #define LogErrorF(format, ...) RM_LOGGER_LOGF_HELPER(Error, format, __VA_ARGS__) #define LogWarningF(format, ...) RM_LOGGER_LOGF_HELPER(Warning, format, __VA_ARGS__) #define LogNoticeF(format, ...) RM_LOGGER_LOGF_HELPER(Notice, format, __VA_ARGS__) diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index fcfdaa5f..6f90e814 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -263,7 +263,7 @@ int Rainmeter::Initialize(LPCWSTR iniPath, LPCWSTR layout) if (!m_Window) return 1; - Logger& logger = Logger::GetInstance(); + Logger& logger = GetLogger(); const WCHAR* iniFile = m_IniFile.c_str(); // Set file locations @@ -1415,7 +1415,7 @@ void Rainmeter::ReadGeneralSettings(const std::wstring& iniFile) m_Debug = 0!=parser.ReadInt(L"Rainmeter", L"Debug", 0); // Read Logging settings - Logger& logger = Logger::GetInstance(); + Logger& logger = GetLogger(); const bool logging = parser.ReadInt(L"Rainmeter", L"Logging", 0) != 0; logger.SetLogToFile(logging); if (logging) @@ -1910,7 +1910,7 @@ void Rainmeter::ShowContextMenu(POINT pos, MeterWindow* meterWindow) { SetMenuDefaultItem(menu, IDM_MANAGE, MF_BYCOMMAND); - if (_waccess(Logger::GetInstance().GetLogFilePath().c_str(), 0) == -1) + if (_waccess(GetLogger().GetLogFilePath().c_str(), 0) == -1) { EnableMenuItem(menu, IDM_SHOWLOGFILE, MF_BYCOMMAND | MF_GRAYED); EnableMenuItem(menu, IDM_DELETELOGFILE, MF_BYCOMMAND | MF_GRAYED); @@ -1920,7 +1920,7 @@ void Rainmeter::ShowContextMenu(POINT pos, MeterWindow* meterWindow) { EnableMenuItem( menu, - (Logger::GetInstance().IsLogToFile()) ? IDM_STARTLOG : IDM_STOPLOG, + (GetLogger().IsLogToFile()) ? IDM_STARTLOG : IDM_STOPLOG, MF_BYCOMMAND | MF_GRAYED); } @@ -2476,7 +2476,7 @@ void Rainmeter::ChangeSkinIndex(HMENU menu, int index) void Rainmeter::ShowLogFile() { - std::wstring logFile = L'"' + Logger::GetInstance().GetLogFilePath(); + std::wstring logFile = L'"' + GetLogger().GetLogFilePath(); logFile += L'"'; CommandHandler::RunFile(m_SkinEditor.c_str(), logFile.c_str()); diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 178e31b2..da7bc662 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -489,15 +489,15 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM break; case IDM_STARTLOG: - Logger::GetInstance().StartLogFile(); + GetLogger().StartLogFile(); break; case IDM_STOPLOG: - Logger::GetInstance().StopLogFile(); + GetLogger().StopLogFile(); break; case IDM_DELETELOGFILE: - Logger::GetInstance().DeleteLogFile(); + GetLogger().DeleteLogFile(); break; case IDM_DEBUGLOG: @@ -676,7 +676,7 @@ LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM return 0; case RAINMETER_QUERY_ID_LOG_PATH: - sendCopyData(Logger::GetInstance().GetLogFilePath()); + sendCopyData(GetLogger().GetLogFilePath()); return 0; case RAINMETER_QUERY_ID_CONFIG_EDITOR: