mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Logger: Cosmetics
This commit is contained in:
parent
04090b232a
commit
bcbfc4d4db
@ -916,7 +916,7 @@ void CommandHandler::DoLogBang(std::vector<std::wstring>& args, MeterWindow* ski
|
||||
}
|
||||
}
|
||||
|
||||
Logger::GetInstance().Log(level, args[0].c_str());
|
||||
GetLogger().Log(level, args[0].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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<typename... Args> \
|
||||
@ -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__)
|
||||
|
@ -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());
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user