Added !Log bang to write to the Rainmeter log

This commit is contained in:
jsmorley 2012-04-02 10:47:13 -04:00
parent 1ae296c3a2
commit da8b11351d
2 changed files with 43 additions and 0 deletions

View File

@ -635,6 +635,44 @@ void CRainmeter::Bang_WriteKeyValue(const WCHAR* arg, CMeterWindow* meterWindow)
} }
} }
/*
** !Log bang
**
*/
void CRainmeter::Bang_Log(const WCHAR* arg)
{
std::vector<std::wstring> subStrings = ParseString(arg);
if (!subStrings.empty())
{
int level = LOG_NOTICE;
if (subStrings.size() > 1)
{
const WCHAR* type = subStrings[1].c_str();
if (_wcsicmp(type, L"ERROR") == 0)
{
level = LOG_ERROR;
}
else if (_wcsicmp(type, L"WARNING") == 0)
{
level = LOG_WARNING;
}
else if (_wcsicmp(type, L"DEBUG") == 0)
{
level = LOG_DEBUG;
}
else if (_wcsicmp(type, L"NOTICE") != 0)
{
Log(LOG_ERROR, L"!Log: Invalid type");
return;
}
}
Log(level, subStrings[0].c_str());
}
}
// ----------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
// //
@ -1935,6 +1973,10 @@ void CRainmeter::ExecuteBang(const std::wstring& name, std::wstring& arg, CMeter
{ {
ResetStats(); ResetStats();
} }
else if (_wcsicmp(bang, L"Log") == 0)
{
Bang_Log(args);
}
else if (_wcsicmp(bang, L"Quit") == 0) else if (_wcsicmp(bang, L"Quit") == 0)
{ {
// Quit needs to be delayed since it crashes if done during Update() // Quit needs to be delayed since it crashes if done during Update()

View File

@ -245,6 +245,7 @@ private:
void Bang_SkinMenu(const WCHAR* arg, CMeterWindow* meterWindow); void Bang_SkinMenu(const WCHAR* arg, CMeterWindow* meterWindow);
void Bang_TrayMenu(); void Bang_TrayMenu();
void Bang_WriteKeyValue(const WCHAR* arg, CMeterWindow* meterWindow); void Bang_WriteKeyValue(const WCHAR* arg, CMeterWindow* meterWindow);
void Bang_Log(const WCHAR* arg);
void ExecuteBang(const std::wstring& name, std::wstring& arg, CMeterWindow* meterWindow); void ExecuteBang(const std::wstring& name, std::wstring& arg, CMeterWindow* meterWindow);