mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
WebParser: Switch to new logging functions
This commit is contained in:
parent
c2530b3761
commit
95e6b4b76f
@ -145,12 +145,10 @@ private:
|
|||||||
|
|
||||||
if (handle)
|
if (handle)
|
||||||
{
|
{
|
||||||
WCHAR buffer[256];
|
RmLogF(nullptr, LOG_DEBUG, L"WebParser: ProxyServer=\"%s\" (type=%s, handle=0x%p)",
|
||||||
_snwprintf_s(buffer, _TRUNCATE, L"WebParser: ProxyServer=\"%s\" (type=%s, handle=0x%p)",
|
|
||||||
proxyName,
|
proxyName,
|
||||||
proxyType == INTERNET_OPEN_TYPE_PRECONFIG ? L"PRECONFIG" : proxyType == INTERNET_OPEN_TYPE_DIRECT ? L"DIRECT" : L"PROXY",
|
proxyType == INTERNET_OPEN_TYPE_PRECONFIG ? L"PRECONFIG" : proxyType == INTERNET_OPEN_TYPE_DIRECT ? L"DIRECT" : L"PROXY",
|
||||||
handle);
|
handle);
|
||||||
RmLog(LOG_DEBUG, buffer);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -209,7 +207,7 @@ struct MeasureData
|
|||||||
std::wstring downloadFile;
|
std::wstring downloadFile;
|
||||||
std::wstring downloadedFile;
|
std::wstring downloadedFile;
|
||||||
std::wstring debugFileLocation;
|
std::wstring debugFileLocation;
|
||||||
LPCWSTR section;
|
void* rm;
|
||||||
void* skin;
|
void* skin;
|
||||||
ProxySetting proxy;
|
ProxySetting proxy;
|
||||||
HANDLE threadHandle;
|
HANDLE threadHandle;
|
||||||
@ -225,6 +223,7 @@ struct MeasureData
|
|||||||
bool forceReload;
|
bool forceReload;
|
||||||
|
|
||||||
MeasureData() :
|
MeasureData() :
|
||||||
|
rm(),
|
||||||
skin(),
|
skin(),
|
||||||
threadHandle(),
|
threadHandle(),
|
||||||
dlThreadHandle(),
|
dlThreadHandle(),
|
||||||
@ -693,7 +692,7 @@ PLUGIN_EXPORT void Initialize(void** data, void* rm)
|
|||||||
g_Measures.push_back(measure);
|
g_Measures.push_back(measure);
|
||||||
|
|
||||||
measure->skin = RmGetSkin(rm);
|
measure->skin = RmGetSkin(rm);
|
||||||
measure->section = RmGetMeasureName(rm);
|
measure->rm = rm;
|
||||||
|
|
||||||
if (g_InstanceCount == 0)
|
if (g_InstanceCount == 0)
|
||||||
{
|
{
|
||||||
@ -769,7 +768,7 @@ PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
|
|||||||
if (measure->debug == 2)
|
if (measure->debug == 2)
|
||||||
{
|
{
|
||||||
measure->debugFileLocation = RmReadPath(rm, L"Debug2File", L"WebParserDump.txt");
|
measure->debugFileLocation = RmReadPath(rm, L"Debug2File", L"WebParserDump.txt");
|
||||||
RmLog(LOG_DEBUG, measure->debugFileLocation.c_str());
|
RmLog(rm, LOG_DEBUG, measure->debugFileLocation.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
LeaveCriticalSection(&g_CriticalSection);
|
LeaveCriticalSection(&g_CriticalSection);
|
||||||
@ -794,13 +793,6 @@ PLUGIN_EXPORT double Update(void* data)
|
|||||||
{
|
{
|
||||||
measure->dlThreadHandle = threadHandle;
|
measure->dlThreadHandle = threadHandle;
|
||||||
}
|
}
|
||||||
else // error
|
|
||||||
{
|
|
||||||
std::wstring log = L"WebParser.dll: [";
|
|
||||||
log += measure->section;
|
|
||||||
log += L"] Failed to begin download thread";
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
measure->updateCounter++;
|
measure->updateCounter++;
|
||||||
@ -838,13 +830,6 @@ PLUGIN_EXPORT double Update(void* data)
|
|||||||
{
|
{
|
||||||
measure->threadHandle = threadHandle;
|
measure->threadHandle = threadHandle;
|
||||||
}
|
}
|
||||||
else // error
|
|
||||||
{
|
|
||||||
std::wstring log = L"WebParser.dll: [";
|
|
||||||
log += measure->section;
|
|
||||||
log += L"] Failed to begin thread";
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
measure->updateCounter++;
|
measure->updateCounter++;
|
||||||
@ -865,6 +850,7 @@ unsigned __stdcall NetworkThreadProc(void* pParam)
|
|||||||
MeasureData* measure = (MeasureData*)pParam;
|
MeasureData* measure = (MeasureData*)pParam;
|
||||||
DWORD dwSize = 0;
|
DWORD dwSize = 0;
|
||||||
|
|
||||||
|
RmLogF(measure->rm, LOG_DEBUG, L"WebParser: Fetching: %s", measure->url.c_str());
|
||||||
BYTE* data = DownloadUrl(measure->proxy.handle, measure->url, &dwSize, measure->forceReload);
|
BYTE* data = DownloadUrl(measure->proxy.handle, measure->url, &dwSize, measure->forceReload);
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
@ -881,11 +867,7 @@ unsigned __stdcall NetworkThreadProc(void* pParam)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::wstring log = L"WebParser.dll: [";
|
RmLog(measure->rm, LOG_ERROR, L"WebParser: Failed to dump debug data");
|
||||||
log += measure->section;
|
|
||||||
log += L"] Failed to dump debug data: ";
|
|
||||||
log += measure->debugFileLocation;
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,10 +942,7 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
{
|
{
|
||||||
// The output vector wasn't big enough
|
// The output vector wasn't big enough
|
||||||
std::wstring log = L"WebParser.dll: [";
|
RmLog(measure->rm, LOG_ERROR, L"WebParser: Too many substrings");
|
||||||
log += measure->section;
|
|
||||||
log += L"] Too many substrings!";
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -977,16 +956,8 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
int substring_length = ovector[2 * i + 1] - ovector[2 * i];
|
int substring_length = ovector[2 * i + 1] - ovector[2 * i];
|
||||||
substring_length = min(substring_length, 256);
|
substring_length = min(substring_length, 256);
|
||||||
|
|
||||||
WCHAR buffer[32];
|
const std::wstring value = StringUtil::WidenUTF8(substring_start, substring_length);
|
||||||
wsprintf(buffer, L"%2d", i);
|
RmLogF(measure->rm, LOG_DEBUG, L"WebParser: Index %2d: %s", i, value.c_str());
|
||||||
|
|
||||||
std::wstring log = L"WebParser.dll: [";
|
|
||||||
log += measure->section;
|
|
||||||
log += L"] (Index ";
|
|
||||||
log += buffer;
|
|
||||||
log += L") ";
|
|
||||||
log += StringUtil::WidenUTF8(substring_start, substring_length);
|
|
||||||
RmLog(LOG_DEBUG, log.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1000,10 +971,7 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::wstring log = L"WebParser.dll: [";
|
RmLog(measure->rm, LOG_WARNING, L"WebParser: Not enough substrings");
|
||||||
log += measure->section;
|
|
||||||
log += L"] Not enough substrings!";
|
|
||||||
RmLog(LOG_WARNING, log.c_str());
|
|
||||||
|
|
||||||
// Clear the old result
|
// Clear the old result
|
||||||
EnterCriticalSection(&g_CriticalSection);
|
EnterCriticalSection(&g_CriticalSection);
|
||||||
@ -1026,8 +994,8 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
// Update the references
|
// Update the references
|
||||||
std::vector<MeasureData*>::iterator i = g_Measures.begin();
|
std::vector<MeasureData*>::iterator i = g_Measures.begin();
|
||||||
std::wstring compareStr = L"[";
|
std::wstring compareStr = L"[";
|
||||||
compareStr += measure->section;
|
compareStr += RmGetMeasureName(measure->rm);
|
||||||
compareStr += L"]";
|
compareStr += L']';
|
||||||
for ( ; i != g_Measures.end(); ++i)
|
for ( ; i != g_Measures.end(); ++i)
|
||||||
{
|
{
|
||||||
if (measure->skin == (*i)->skin &&
|
if (measure->skin == (*i)->skin &&
|
||||||
@ -1067,13 +1035,6 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
{
|
{
|
||||||
(*i)->dlThreadHandle = threadHandle;
|
(*i)->dlThreadHandle = threadHandle;
|
||||||
}
|
}
|
||||||
else // error
|
|
||||||
{
|
|
||||||
std::wstring log = L"WebParser.dll: [";
|
|
||||||
log += (*i)->section;
|
|
||||||
log += L"] Failed to begin download thread";
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LeaveCriticalSection(&g_CriticalSection);
|
LeaveCriticalSection(&g_CriticalSection);
|
||||||
@ -1081,10 +1042,7 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::wstring log = L"WebParser.dll: [";
|
RmLog((*i)->rm, LOG_WARNING, L"WebParser: Not enough substrings");
|
||||||
log += (*i)->section;
|
|
||||||
log += L"] Not enough substrings!";
|
|
||||||
RmLog(LOG_WARNING, log.c_str());
|
|
||||||
|
|
||||||
// Clear the old result
|
// Clear the old result
|
||||||
EnterCriticalSection(&g_CriticalSection);
|
EnterCriticalSection(&g_CriticalSection);
|
||||||
@ -1110,15 +1068,7 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Matching failed: handle error cases
|
// Matching failed: handle error cases
|
||||||
WCHAR buffer[32];
|
RmLogF(measure->rm, LOG_ERROR, L"WebParser: RegExp matching error (%d)", rc);
|
||||||
wsprintf(buffer, L"%d", rc);
|
|
||||||
|
|
||||||
std::wstring log = L"WebParser.dll: [";
|
|
||||||
log += measure->section;
|
|
||||||
log += L"] Matching error! (";
|
|
||||||
log += buffer;
|
|
||||||
log += L')';
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
|
|
||||||
EnterCriticalSection(&g_CriticalSection);
|
EnterCriticalSection(&g_CriticalSection);
|
||||||
measure->resultString = measure->errorString;
|
measure->resultString = measure->errorString;
|
||||||
@ -1126,8 +1076,8 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
// Update the references
|
// Update the references
|
||||||
std::vector<MeasureData*>::iterator i = g_Measures.begin();
|
std::vector<MeasureData*>::iterator i = g_Measures.begin();
|
||||||
std::wstring compareStr = L"[";
|
std::wstring compareStr = L"[";
|
||||||
compareStr += measure->section;
|
compareStr += RmGetMeasureName(measure->rm);
|
||||||
compareStr += L"]";
|
compareStr += L']';
|
||||||
for ( ; i != g_Measures.end(); ++i)
|
for ( ; i != g_Measures.end(); ++i)
|
||||||
{
|
{
|
||||||
if (((*i)->url.find(compareStr) != std::wstring::npos) && (measure->skin == (*i)->skin))
|
if (((*i)->url.find(compareStr) != std::wstring::npos) && (measure->skin == (*i)->skin))
|
||||||
@ -1143,17 +1093,8 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Compilation failed: print the error message and exit
|
// Compilation failed.
|
||||||
WCHAR buffer[32];
|
RmLogF(measure->rm, LOG_ERROR, L"WebParser: RegExp error at offset %d: %S", erroffset, error);
|
||||||
wsprintf(buffer, L"%d", erroffset);
|
|
||||||
|
|
||||||
std::wstring log = L"WebParser.dll: [";
|
|
||||||
log += measure->section;
|
|
||||||
log += L"] PCRE compilation failed at offset ";
|
|
||||||
log += buffer;
|
|
||||||
log += L": ";
|
|
||||||
log += StringUtil::Widen(error);
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (measure->download)
|
if (measure->download)
|
||||||
@ -1165,13 +1106,6 @@ void ParseData(MeasureData* measure, LPCSTR parseData, DWORD dwSize)
|
|||||||
{
|
{
|
||||||
measure->dlThreadHandle = threadHandle;
|
measure->dlThreadHandle = threadHandle;
|
||||||
}
|
}
|
||||||
else // error
|
|
||||||
{
|
|
||||||
std::wstring log = L"WebParser.dll: [";
|
|
||||||
log += measure->section;
|
|
||||||
log += L"] Failed to begin download thread";
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1307,27 +1241,19 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
|
|
||||||
if (download) // download mode
|
if (download) // download mode
|
||||||
{
|
{
|
||||||
std::wstring log;
|
|
||||||
|
|
||||||
if (!PathFileExists(directory.c_str()) || !PathIsDirectory(directory.c_str()))
|
if (!PathFileExists(directory.c_str()) || !PathIsDirectory(directory.c_str()))
|
||||||
{
|
{
|
||||||
ready = false;
|
ready = false;
|
||||||
|
RmLogF(
|
||||||
log = L"WebParser.dll: [";
|
measure->rm, LOG_ERROR,
|
||||||
log += measure->section;
|
L"WebParser: Directory does not exist: %s", directory.c_str());
|
||||||
log += L"] Directory does not exist: ";
|
|
||||||
log += directory;
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
}
|
||||||
else if (PathIsDirectory(fullpath.c_str()))
|
else if (PathIsDirectory(fullpath.c_str()))
|
||||||
{
|
{
|
||||||
ready = false;
|
ready = false;
|
||||||
|
RmLogF(
|
||||||
log = L"WebParser.dll: [";
|
measure->rm, LOG_ERROR,
|
||||||
log += measure->section;
|
L"WebParser: Path is a directory, not a file: %s", fullpath.c_str());
|
||||||
log += L"] Path is a directory, not a file: ";
|
|
||||||
log += fullpath;
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
}
|
||||||
else if (PathFileExists(fullpath.c_str()))
|
else if (PathFileExists(fullpath.c_str()))
|
||||||
{
|
{
|
||||||
@ -1335,12 +1261,9 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_READONLY))
|
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_READONLY))
|
||||||
{
|
{
|
||||||
ready = false;
|
ready = false;
|
||||||
|
RmLogF(
|
||||||
log = L"WebParser.dll: [";
|
measure->rm, LOG_ERROR,
|
||||||
log += measure->section;
|
L"WebParser: File is read-only: %s", fullpath.c_str());
|
||||||
log += L"] File is READ-ONLY: ";
|
|
||||||
log += fullpath;
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1424,14 +1347,9 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write some log info
|
RmLogF(
|
||||||
std::wstring log = L"WebParser.dll: [";
|
measure->rm, LOG_DEBUG,
|
||||||
log += measure->section;
|
L"WebParser: Downloading url '%s' to: %s", url.c_str(), fullpath.c_str());
|
||||||
log += L"] Downloading url ";
|
|
||||||
log += url;
|
|
||||||
log += L" to ";
|
|
||||||
log += fullpath;
|
|
||||||
RmLog(LOG_DEBUG, log.c_str());
|
|
||||||
|
|
||||||
HRESULT resultCoInitialize = CoInitialize(nullptr); // requires before calling URLDownloadToFile function
|
HRESULT resultCoInitialize = CoInitialize(nullptr); // requires before calling URLDownloadToFile function
|
||||||
|
|
||||||
@ -1478,15 +1396,10 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
DeleteFile(fullpath.c_str());
|
DeleteFile(fullpath.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
wsprintf(buffer, L"result=0x%08X, COM=0x%08X", result, resultCoInitialize);
|
RmLogF(
|
||||||
|
measure->rm, LOG_ERROR,
|
||||||
std::wstring log = L"WebParser.dll: [";
|
L"WebParser: Download failed (res=0x%08X, COM=0x%08X): %s",
|
||||||
log += measure->section;
|
result, resultCoInitialize, url.c_str());
|
||||||
log += L"] Download failed (";
|
|
||||||
log += buffer;
|
|
||||||
log += L"): ";
|
|
||||||
log += url;
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(resultCoInitialize))
|
if (SUCCEEDED(resultCoInitialize))
|
||||||
@ -1496,19 +1409,12 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::wstring log = L"WebParser.dll: [";
|
RmLogF(measure->rm, LOG_ERROR, L"WebParser: Download failed: %s", url.c_str());
|
||||||
log += measure->section;
|
|
||||||
log += L"] Download failed: ";
|
|
||||||
log += url;
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::wstring log = L"WebParser.dll: [";
|
RmLog(measure->rm, LOG_ERROR, L"WebParser: Url is empty");
|
||||||
log += measure->section;
|
|
||||||
log += L"] Url is empty";
|
|
||||||
RmLog(LOG_ERROR, log.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ready) // download failed
|
if (!ready) // download failed
|
||||||
@ -1617,9 +1523,6 @@ PLUGIN_EXPORT void Finalize(void* data)
|
|||||||
*/
|
*/
|
||||||
BYTE* DownloadUrl(HINTERNET handle, std::wstring& url, DWORD* dataSize, bool forceReload)
|
BYTE* DownloadUrl(HINTERNET handle, std::wstring& url, DWORD* dataSize, bool forceReload)
|
||||||
{
|
{
|
||||||
std::wstring err = L"WebParser.dll: Fetching: " + url;
|
|
||||||
RmLog(LOG_DEBUG, err.c_str());
|
|
||||||
|
|
||||||
DWORD flags = INTERNET_FLAG_RESYNCHRONIZE;
|
DWORD flags = INTERNET_FLAG_RESYNCHRONIZE;
|
||||||
if (forceReload)
|
if (forceReload)
|
||||||
{
|
{
|
||||||
@ -1686,76 +1589,49 @@ BYTE* DownloadUrl(HINTERNET handle, std::wstring& url, DWORD* dataSize, bool for
|
|||||||
*/
|
*/
|
||||||
void ShowError(int lineNumber, WCHAR* errorMsg)
|
void ShowError(int lineNumber, WCHAR* errorMsg)
|
||||||
{
|
{
|
||||||
DWORD dwErr = GetLastError();
|
if (errorMsg)
|
||||||
|
|
||||||
WCHAR buffer[16];
|
|
||||||
wsprintf(buffer, L"%i", lineNumber);
|
|
||||||
|
|
||||||
std::wstring err = L"WebParser.dll: (";
|
|
||||||
err += buffer;
|
|
||||||
err += L") ";
|
|
||||||
|
|
||||||
if (errorMsg == nullptr)
|
|
||||||
{
|
{
|
||||||
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
|
RmLogF(nullptr, LOG_ERROR, L"WebParser: (%i) %s", lineNumber, errorMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD dwErr = GetLastError();
|
||||||
|
if (dwErr == ERROR_INTERNET_EXTENDED_ERROR)
|
||||||
|
{
|
||||||
|
WCHAR szBuffer[1024];
|
||||||
|
DWORD dwError, dwLen = 1024;
|
||||||
|
const WCHAR* error = L"Unknown error";
|
||||||
|
if (InternetGetLastResponseInfo(&dwError, szBuffer, &dwLen))
|
||||||
{
|
{
|
||||||
WCHAR szBuffer[1024];
|
error = szBuffer;
|
||||||
DWORD dwError, dwLen = 1024;
|
dwErr = dwError;
|
||||||
if (InternetGetLastResponseInfo(&dwError, szBuffer, &dwLen))
|
|
||||||
{
|
|
||||||
err += szBuffer;
|
|
||||||
wsprintf(buffer, L"%i", dwError);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
err += L"Unknown error";
|
|
||||||
wsprintf(buffer, L"%i", dwErr);
|
|
||||||
}
|
|
||||||
|
|
||||||
err += L" (ErrorCode=";
|
|
||||||
err += buffer;
|
|
||||||
err += L')';
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
LPVOID lpMsgBuf = nullptr;
|
|
||||||
|
|
||||||
FormatMessage(
|
RmLogF(nullptr, LOG_ERROR, L"WebParser: (%i) %s (ErrorCode=%i)", lineNumber, error, dwErr);
|
||||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
||||||
FORMAT_MESSAGE_FROM_HMODULE |
|
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS |
|
|
||||||
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
|
||||||
GetModuleHandle(L"wininet"),
|
|
||||||
dwErr,
|
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
|
||||||
(LPTSTR) &lpMsgBuf,
|
|
||||||
0,
|
|
||||||
nullptr
|
|
||||||
);
|
|
||||||
|
|
||||||
if (lpMsgBuf == nullptr)
|
|
||||||
{
|
|
||||||
err += L"Unknown error";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
err += (LPTSTR)lpMsgBuf;
|
|
||||||
LocalFree(lpMsgBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
wsprintf(buffer, L"%i", dwErr);
|
|
||||||
err += L" (ErrorCode=";
|
|
||||||
err += buffer;
|
|
||||||
err += L')';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err += errorMsg;
|
LPVOID lpMsgBuf = nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
RmLog(LOG_ERROR, err.c_str());
|
FormatMessage(
|
||||||
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||||
|
FORMAT_MESSAGE_FROM_HMODULE |
|
||||||
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
|
FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||||
|
FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
||||||
|
GetModuleHandle(L"wininet"),
|
||||||
|
dwErr,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||||
|
(LPTSTR) &lpMsgBuf,
|
||||||
|
0,
|
||||||
|
nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
const WCHAR* error = lpMsgBuf ? (WCHAR*)lpMsgBuf : L"Unknown error";
|
||||||
|
RmLogF(nullptr, LOG_ERROR, L"WebParser: (%i) %s (ErrorCode=%i)", lineNumber, error, dwErr);
|
||||||
|
|
||||||
|
if (lpMsgBuf) LocalFree(lpMsgBuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PLUGIN_EXPORT void ExecuteBang(void* data, LPCWSTR args)
|
PLUGIN_EXPORT void ExecuteBang(void* data, LPCWSTR args)
|
||||||
|
Loading…
Reference in New Issue
Block a user