mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
WebParser: Errors and warnings are now logged as errors and warnings (instead of as debug)
This commit is contained in:
parent
c0579e3b24
commit
c8694ccf16
@ -74,7 +74,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwSize, bool forceReload);
|
|||||||
void ShowError(int lineNumber, WCHAR* errorMsg = NULL);
|
void ShowError(int lineNumber, WCHAR* errorMsg = NULL);
|
||||||
unsigned __stdcall NetworkThreadProc(void* pParam);
|
unsigned __stdcall NetworkThreadProc(void* pParam);
|
||||||
unsigned __stdcall NetworkDownloadThreadProc(void* pParam);
|
unsigned __stdcall NetworkDownloadThreadProc(void* pParam);
|
||||||
void Log(const WCHAR* string);
|
void Log(int level, const WCHAR* string);
|
||||||
void ParseData(UrlData* urlData, LPCSTR parseData);
|
void ParseData(UrlData* urlData, LPCSTR parseData);
|
||||||
|
|
||||||
CRITICAL_SECTION g_CriticalSection;
|
CRITICAL_SECTION g_CriticalSection;
|
||||||
@ -608,7 +608,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
|||||||
{
|
{
|
||||||
std::wstring str = data->iniFile.substr(0,data->iniFile.find_last_of(L"\\")+1);
|
std::wstring str = data->iniFile.substr(0,data->iniFile.find_last_of(L"\\")+1);
|
||||||
str += data->debugFileLocation;
|
str += data->debugFileLocation;
|
||||||
Log(str.c_str());
|
Log(LOG_DEBUG, str.c_str());
|
||||||
data->debugFileLocation = str;
|
data->debugFileLocation = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,7 +733,7 @@ double Update2(UINT id)
|
|||||||
std::wstring log = L"WebParser: [";
|
std::wstring log = L"WebParser: [";
|
||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] Failed to begin download thread.";
|
log += L"] Failed to begin download thread.";
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -777,7 +777,7 @@ double Update2(UINT id)
|
|||||||
std::wstring log = L"WebParser: [";
|
std::wstring log = L"WebParser: [";
|
||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] Failed to begin thread.";
|
log += L"] Failed to begin thread.";
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,7 +824,7 @@ unsigned __stdcall NetworkThreadProc(void* pParam)
|
|||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] Failed to dump debug data: ";
|
log += L"] Failed to dump debug data: ";
|
||||||
log += urlData->debugFileLocation;
|
log += urlData->debugFileLocation;
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -905,7 +905,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
|||||||
std::wstring log = L"WebParser: [";
|
std::wstring log = L"WebParser: [";
|
||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] Too many substrings!";
|
log += L"] Too many substrings!";
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -929,7 +929,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
|||||||
log += buffer;
|
log += buffer;
|
||||||
log += L") ";
|
log += L") ";
|
||||||
log += ConvertUTF8ToWide(tmpStr.c_str());
|
log += ConvertUTF8ToWide(tmpStr.c_str());
|
||||||
Log(log.c_str());
|
Log(LOG_DEBUG, log.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,7 +946,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
|||||||
std::wstring log = L"WebParser: [";
|
std::wstring log = L"WebParser: [";
|
||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] Not enough substrings!";
|
log += L"] Not enough substrings!";
|
||||||
Log(log.c_str());
|
Log(LOG_WARNING, log.c_str());
|
||||||
|
|
||||||
// Clear the old result
|
// Clear the old result
|
||||||
EnterCriticalSection(&g_CriticalSection);
|
EnterCriticalSection(&g_CriticalSection);
|
||||||
@ -1017,7 +1017,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
|||||||
std::wstring log = L"WebParser: [";
|
std::wstring log = L"WebParser: [";
|
||||||
log += (*i).second->section;
|
log += (*i).second->section;
|
||||||
log += L"] Failed to begin download thread.";
|
log += L"] Failed to begin download thread.";
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1029,7 +1029,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
|||||||
std::wstring log = L"WebParser: [";
|
std::wstring log = L"WebParser: [";
|
||||||
log += (*i).second->section;
|
log += (*i).second->section;
|
||||||
log += L"] Not enough substrings!";
|
log += L"] Not enough substrings!";
|
||||||
Log(log.c_str());
|
Log(LOG_WARNING, log.c_str());
|
||||||
|
|
||||||
// Clear the old result
|
// Clear the old result
|
||||||
EnterCriticalSection(&g_CriticalSection);
|
EnterCriticalSection(&g_CriticalSection);
|
||||||
@ -1063,7 +1063,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
|||||||
log += L"] Matching error! (";
|
log += L"] Matching error! (";
|
||||||
log += buffer;
|
log += buffer;
|
||||||
log += L")\n";
|
log += L")\n";
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
|
|
||||||
EnterCriticalSection(&g_CriticalSection);
|
EnterCriticalSection(&g_CriticalSection);
|
||||||
urlData->resultString = urlData->errorString;
|
urlData->resultString = urlData->errorString;
|
||||||
@ -1099,7 +1099,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
|||||||
log += L": ";
|
log += L": ";
|
||||||
log += ConvertAsciiToWide(error);
|
log += ConvertAsciiToWide(error);
|
||||||
log += L"\n";
|
log += L"\n";
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (urlData->download)
|
if (urlData->download)
|
||||||
@ -1116,7 +1116,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData)
|
|||||||
std::wstring log = L"WebParser: [";
|
std::wstring log = L"WebParser: [";
|
||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] Failed to begin download thread.";
|
log += L"] Failed to begin download thread.";
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1276,10 +1276,9 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
|
|
||||||
log = L"WebParser: [";
|
log = L"WebParser: [";
|
||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] Directory not exists: ";
|
log += L"] Directory does not exist: ";
|
||||||
log += directory;
|
log += directory;
|
||||||
log += L"\n";
|
Log(LOG_ERROR, log.c_str());
|
||||||
Log(log.c_str());
|
|
||||||
}
|
}
|
||||||
else if (PathIsDirectory(fullpath.c_str()))
|
else if (PathIsDirectory(fullpath.c_str()))
|
||||||
{
|
{
|
||||||
@ -1289,8 +1288,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] Path is a directory, not a file: ";
|
log += L"] Path is a directory, not a file: ";
|
||||||
log += fullpath;
|
log += fullpath;
|
||||||
log += L"\n";
|
Log(LOG_ERROR, log.c_str());
|
||||||
Log(log.c_str());
|
|
||||||
}
|
}
|
||||||
else if (PathFileExists(fullpath.c_str()))
|
else if (PathFileExists(fullpath.c_str()))
|
||||||
{
|
{
|
||||||
@ -1303,8 +1301,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] File is READ-ONLY: ";
|
log += L"] File is READ-ONLY: ";
|
||||||
log += fullpath;
|
log += fullpath;
|
||||||
log += L"\n";
|
Log(LOG_ERROR, log.c_str());
|
||||||
Log(log.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1396,7 +1393,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
log += L" to ";
|
log += L" to ";
|
||||||
log += fullpath;
|
log += fullpath;
|
||||||
log += L"\n";
|
log += L"\n";
|
||||||
Log(log.c_str());
|
Log(LOG_DEBUG, log.c_str());
|
||||||
|
|
||||||
HRESULT resultCoInitialize = CoInitialize(NULL); // requires before calling URLDownloadToFile function
|
HRESULT resultCoInitialize = CoInitialize(NULL); // requires before calling URLDownloadToFile function
|
||||||
|
|
||||||
@ -1463,7 +1460,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
log += buffer;
|
log += buffer;
|
||||||
log += L"): ";
|
log += L"): ";
|
||||||
log += url;
|
log += url;
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(resultCoInitialize))
|
if (SUCCEEDED(resultCoInitialize))
|
||||||
@ -1477,7 +1474,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] Download failed: ";
|
log += L"] Download failed: ";
|
||||||
log += url;
|
log += url;
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1485,7 +1482,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
std::wstring log = L"WebParser: [";
|
std::wstring log = L"WebParser: [";
|
||||||
log += urlData->section;
|
log += urlData->section;
|
||||||
log += L"] The url is empty.\n";
|
log += L"] The url is empty.\n";
|
||||||
Log(log.c_str());
|
Log(LOG_ERROR, log.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ready) // download failed
|
if (!ready) // download failed
|
||||||
@ -1624,7 +1621,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
|||||||
|
|
||||||
std::wstring err = L"WebParser: Fetching URL: ";
|
std::wstring err = L"WebParser: Fetching URL: ";
|
||||||
err += url;
|
err += url;
|
||||||
Log(err.c_str());
|
Log(LOG_DEBUG, err.c_str());
|
||||||
|
|
||||||
DWORD flags = INTERNET_FLAG_RESYNCHRONIZE;
|
DWORD flags = INTERNET_FLAG_RESYNCHRONIZE;
|
||||||
if (forceReload)
|
if (forceReload)
|
||||||
@ -1717,7 +1714,7 @@ BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize, bool forceReload)
|
|||||||
|
|
||||||
err = L"WebParser: Finished URL: ";
|
err = L"WebParser: Finished URL: ";
|
||||||
err += url;
|
err += url;
|
||||||
Log(err.c_str());
|
Log(LOG_DEBUG, err.c_str());
|
||||||
|
|
||||||
// Delete the existing buffers.
|
// Delete the existing buffers.
|
||||||
delete [] lpData;
|
delete [] lpData;
|
||||||
@ -1800,16 +1797,15 @@ void ShowError(int lineNumber, WCHAR* errorMsg)
|
|||||||
err += errorMsg;
|
err += errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(err.c_str());
|
Log(LOG_ERROR, err.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Writes the log to a file (logging is thread safe (I think...)).
|
Writes the log to a file (logging is thread safe (I think...)).
|
||||||
*/
|
*/
|
||||||
void Log(const WCHAR* string)
|
void Log(int level, const WCHAR* string)
|
||||||
{
|
{
|
||||||
// Todo: put logging into critical section
|
LSLog(level, L"Rainmeter", string);
|
||||||
LSLog(LOG_DEBUG, L"Rainmeter", string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT GetPluginVersion()
|
UINT GetPluginVersion()
|
||||||
|
Loading…
Reference in New Issue
Block a user