- Replace DebugLog() with LogWithArgs(int nLevel, const WCHAR* format, ... ), so that variable strings can be logged but the log level can be set to those other than LOG_DEBUG

- Note: DebugLog() is still in the code as I was not sure whether it is required to maintain Litestep interoperability
- Replaced instances of LOG_DEBUG where other log levels would be more appropriate
This commit is contained in:
JamesAC
2010-12-19 23:06:13 +00:00
parent 56d472d5b5
commit c50f1c27f2
27 changed files with 211 additions and 187 deletions

View File

@ -139,7 +139,7 @@ double Update2(UINT id)
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"PerfMon plugin works only in Win2K and later.");
LSLog(LOG_NOTICE, L"Rainmeter", L"PerfMon plugin works only in Win2K and later.");
}
}
}

View File

@ -155,14 +155,14 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Unable to get the host by name.");
LSLog(LOG_WARNING, L"Rainmeter", L"Unable to get the host by name.");
}
WSACleanup();
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Unable to initialize Windows Sockets.");
LSLog(LOG_WARNING, L"Rainmeter", L"Unable to initialize Windows Sockets.");
}
}
valid = true;
@ -290,7 +290,7 @@ void Finalize(HMODULE instance, UINT id)
if ((*i1).second->threadHandle)
{
// Should really wait until the thread finishes instead terminating it...
LSLog(LOG_DEBUG, L"Rainmeter", L"PingPlugin: Thread still running -> Terminate.");
LSLog(LOG_NOTICE, L"Rainmeter", L"PingPlugin: Thread still running -> Terminate.");
TerminateThread((*i1).second->threadHandle, 0);
}
LeaveCriticalSection(&g_CriticalSection);

View File

@ -268,7 +268,7 @@ bool ReadSharedData(SensorType type, TempScale scale, UINT number, double* value
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"SpeedFanPlugin: The shared memory has incorrect version.");
LSLog(LOG_WARNING, L"Rainmeter", L"SpeedFanPlugin: The shared memory has incorrect version.");
}
UnmapViewOfFile(ptr);

View File

@ -85,7 +85,7 @@ bool InitCom()
if (!com_initialized) com_initialized = SUCCEEDED(CoInitialize(0));
if (!com_initialized)
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: COM initialization failed!");
LSLog(LOG_ERROR, L"Rainmeter", L"Win7AudioPlugin: COM initialization failed!");
return false;
}
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, 0, CLSCTX_ALL,
@ -104,12 +104,12 @@ bool InitCom()
dbg_str += e_code;
}
LSLog(LOG_DEBUG, L"Rainmeter", dbg_str.c_str());
LSLog(LOG_ERROR, L"Rainmeter", dbg_str.c_str());
return CleanUp() != 0;
}
if (S_OK != pEnumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pCollection) || !pCollection)
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Could not enumerate AudioEndpoints!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: Could not enumerate AudioEndpoints!");
return CleanUp() != 0;
}
return true;
@ -145,7 +145,7 @@ HRESULT RegisterDevice(PCWSTR devID)
}
catch (...)
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: RegisterDevice - Exception!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: RegisterDevice - Exception!");
hr = S_FALSE;
}
UnInitCom();
@ -170,7 +170,7 @@ std::wstring GetDefaultID()
}
catch (...)
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: GetDefaultID - Exception!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: GetDefaultID - Exception!");
id_default = L"Exception";
}
SAFE_RELEASE(pEndpoint)
@ -207,7 +207,7 @@ bool GetWin7AudioState(const VolumeAction action)
}
catch (...)
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Win7ToggleMute - Exception!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: Win7ToggleMute - Exception!");
}
SAFE_RELEASE(pEndptVol)
SAFE_RELEASE(pEndpoint)
@ -266,7 +266,7 @@ bool SetWin7Volume(UINT volume, int offset = 0)
}
catch (...)
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: SetWin7Volume - Exception!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: SetWin7Volume - Exception!");
}
SAFE_RELEASE(pEndptVol)
SAFE_RELEASE(pEndpoint)
@ -396,7 +396,7 @@ LPCTSTR GetString(UINT id, UINT flags)
wsprintf(result, L"ERROR - Getting Default Device");
}
} catch (...) {
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: GetString - Exception!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: GetString - Exception!");
wsprintf(result, L"Exception");
}
UnInitCom();
@ -441,7 +441,7 @@ void ExecuteBang(LPCTSTR args, UINT id)
{
if (endpointIDs.size() <= 0)
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: No device found!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: No device found!");
return;
}
// set to endpoint [index-1]
@ -451,7 +451,7 @@ void ExecuteBang(LPCTSTR args, UINT id)
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Incorrect number of arguments for the bang!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: Incorrect number of arguments for the bang!");
}
}
else if (_wcsicmp(bang.c_str(), L"SetVolume") == 0)
@ -462,12 +462,12 @@ void ExecuteBang(LPCTSTR args, UINT id)
{
if (!SetWin7Volume(volume < 0 ? 0 : (volume > 100 ? 100 : (UINT)volume)))
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Error setting volume!");
LSLog(LOG_ERROR, L"Rainmeter", L"Win7AudioPlugin: Error setting volume!");
}
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Incorrect number of arguments for the bang!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: Incorrect number of arguments for the bang!");
}
}
else if (_wcsicmp(bang.c_str(), L"ChangeVolume") == 0)
@ -478,17 +478,17 @@ void ExecuteBang(LPCTSTR args, UINT id)
{
if (!SetWin7Volume(0, offset))
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Error changing volume!");
LSLog(LOG_ERROR, L"Rainmeter", L"Win7AudioPlugin: Error changing volume!");
}
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Incorrect number of arguments for the bang!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: Incorrect number of arguments for the bang!");
}
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Unknown bang!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: Unknown bang!");
}
}
@ -497,17 +497,17 @@ void ExecuteBang(LPCTSTR args, UINT id)
//LSLog(LOG_NOTICE, L"Rainmeter", L"Win7AudioPlugin: Next device.");
const UINT i = GetIndex();
if (i) RegisterDevice(endpointIDs[(i == endpointIDs.size()) ? 0 : i].c_str());
else LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Update error - Try refresh!");
else LSLog(LOG_ERROR, L"Rainmeter", L"Win7AudioPlugin: Update error - Try refresh!");
}
else if (_wcsicmp(wholeBang.c_str(), L"TogglePrevious") == 0)
{
const UINT i = GetIndex();
if (i) RegisterDevice(endpointIDs[(i == 1) ? endpointIDs.size() - 1 : i - 2].c_str());
else LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Update error - Try refresh!");
else LSLog(LOG_ERROR, L"Rainmeter", L"Win7AudioPlugin: Update error - Try refresh!");
}
else if (_wcsicmp(wholeBang.c_str(), L"ToggleMute") == 0)
{
if (!GetWin7AudioState(TOGGLE_MUTE)) LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Mute Toggle Error!");
if (!GetWin7AudioState(TOGGLE_MUTE)) LSLog(LOG_ERROR, L"Rainmeter", L"Win7AudioPlugin: Mute Toggle Error!");
}
else if (_wcsicmp(wholeBang.c_str(), L"Mute") == 0)
{
@ -515,7 +515,7 @@ void ExecuteBang(LPCTSTR args, UINT id)
{
if (!GetWin7AudioState(TOGGLE_MUTE))
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Mute Error!");
LSLog(LOG_ERROR, L"Rainmeter", L"Win7AudioPlugin: Mute Error!");
}
}
}
@ -525,12 +525,12 @@ void ExecuteBang(LPCTSTR args, UINT id)
{
if (!GetWin7AudioState(TOGGLE_MUTE))
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Unmute Error!");
LSLog(LOG_ERROR, L"Rainmeter", L"Win7AudioPlugin: Unmute Error!");
}
}
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Unknown bang!");
LSLog(LOG_WARNING, L"Rainmeter", L"Win7AudioPlugin: Unknown bang!");
}
}

View File

@ -208,26 +208,26 @@ void ExecuteBang(LPCTSTR args, UINT id)
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Unable to find the window!");
LSLog(LOG_ERROR, L"Rainmeter", L"WindowMessagePlugin: Unable to find the window!");
}
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Unable to find the window data!");
LSLog(LOG_ERROR, L"Rainmeter", L"WindowMessagePlugin: Unable to find the window data!");
}
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Incorrect number of arguments for the bang!");
LSLog(LOG_WARNING, L"Rainmeter", L"WindowMessagePlugin: Incorrect number of arguments for the bang!");
}
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Unknown bang!");
LSLog(LOG_WARNING, L"Rainmeter", L"WindowMessagePlugin: Unknown bang!");
}
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Unable to parse the bang!");
LSLog(LOG_WARNING, L"Rainmeter", L"WindowMessagePlugin: Unable to parse the bang!");
}
}

View File

@ -456,17 +456,17 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
if (SUCCEEDED(iTunes.CreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER)))
{
InstanceCreated = true;
LSLog(LOG_DEBUG, L"Rainmeter", L"iTunesPlugin: iTunesApp initialized successfully.");
LSLog(LOG_NOTICE, L"Rainmeter", L"iTunesPlugin: iTunesApp initialized successfully.");
initEventHandler();
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"iTunesPlugin: Unable to create the iTunesApp instance.");
LSLog(LOG_WARNING, L"Rainmeter", L"iTunesPlugin: Unable to create the iTunesApp instance.");
}
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"iTunesPlugin: Unable to find the iTunes window.");
LSLog(LOG_WARNING, L"Rainmeter", L"iTunesPlugin: Unable to find the iTunes window.");
}
const wchar_t* type = ReadConfigString(section, L"Command", L"");
@ -501,12 +501,12 @@ UINT Update(UINT id)
if (!iTunesAboutToPromptUserToQuit && SUCCEEDED(iTunes.CreateInstance(CLSID_iTunesApp, NULL, CLSCTX_LOCAL_SERVER)))
{
InstanceCreated = true;
LSLog(LOG_DEBUG, L"Rainmeter", L"iTunesPlugin: iTunesApp initialized successfully.");
LSLog(LOG_NOTICE, L"Rainmeter", L"iTunesPlugin: iTunesApp initialized successfully.");
initEventHandler();
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"iTunesPlugin: Unable to create the iTunesApp instance.");
LSLog(LOG_WARNING, L"Rainmeter", L"iTunesPlugin: Unable to create the iTunesApp instance.");
return 0;
}
}
@ -776,7 +776,7 @@ void ExecuteBang(LPCTSTR args, UINT id)
}
else
{
LSLog(LOG_DEBUG, L"Rainmeter", L"iTunesPlugin: Invalid command.");
LSLog(LOG_NOTICE, L"Rainmeter", L"iTunesPlugin: Invalid command.");
return;
}
}