Fixed updater's logging.
This commit is contained in:
@@ -46,13 +46,6 @@ UINT WINAPI Updater(void*) {
|
|||||||
logger.Out(L"[UPDT] %s(%d): Parsing JSON object", TEXT(__FUNCTION__), __LINE__);
|
logger.Out(L"[UPDT] %s(%d): Parsing JSON object", TEXT(__FUNCTION__), __LINE__);
|
||||||
|
|
||||||
obj = json.get<picojson::object>();
|
obj = json.get<picojson::object>();
|
||||||
it = obj.find("message"), it2;
|
|
||||||
if (it != obj.end()) {
|
|
||||||
std::string u = (*it).second.get<std::string>();
|
|
||||||
logger.Out(L"[UPDT] %s(%d): Error! The url is %S", TEXT(__FUNCTION__), __LINE__, u);
|
|
||||||
return 102;
|
|
||||||
_endthreadex(102);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (it = obj.begin(); it != obj.end(); it++) {
|
for (it = obj.begin(); it != obj.end(); it++) {
|
||||||
if ((*it).first == "tag_name") j_tag_name = ConvertUtf8ToWide((*it).second.to_str());
|
if ((*it).first == "tag_name") j_tag_name = ConvertUtf8ToWide((*it).second.to_str());
|
||||||
@@ -70,8 +63,8 @@ UINT WINAPI Updater(void*) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.Out(L"[UPDT] %s(%d): Error! Cannot recognize JSON object!", TEXT(__FUNCTION__), __LINE__);
|
logger.Out(L"[UPDT] %s(%d): Error! Cannot recognize JSON object!", TEXT(__FUNCTION__), __LINE__);
|
||||||
return 103;
|
return 102;
|
||||||
_endthreadex(103);
|
_endthreadex(102);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
@@ -127,14 +120,13 @@ bool GetLatestRelease(const std::wstring& urn) {
|
|||||||
if (hRequest != NULL) {
|
if (hRequest != NULL) {
|
||||||
BOOL isSend = HttpSendRequestW(hRequest, NULL, 0, 0, 0);
|
BOOL isSend = HttpSendRequestW(hRequest, NULL, 0, 0, 0);
|
||||||
if (isSend) {
|
if (isSend) {
|
||||||
char szData[1024]{ 0 };
|
char szData[1024] { 0 };
|
||||||
DWORD dwBytesRead = 0;
|
DWORD dwBytesRead = 0;
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
do {
|
do {
|
||||||
InternetReadFile(hRequest, szData, sizeof(szData), &dwBytesRead);
|
InternetReadFile(hRequest, szData, sizeof(szData), &dwBytesRead);
|
||||||
buffer.append(szData, dwBytesRead);
|
buffer.append(szData, dwBytesRead);
|
||||||
}
|
} while (dwBytesRead != 0);
|
||||||
while (dwBytesRead != 0);
|
|
||||||
|
|
||||||
picojson::parse(json, buffer);
|
picojson::parse(json, buffer);
|
||||||
std::string jerr = picojson::get_last_error();
|
std::string jerr = picojson::get_last_error();
|
||||||
@@ -144,7 +136,18 @@ bool GetLatestRelease(const std::wstring& urn) {
|
|||||||
MessageBoxW(NULL, L"Error while parsing JSON object!", szTitle, MB_OK | MB_ICONERROR);
|
MessageBoxW(NULL, L"Error while parsing JSON object!", szTitle, MB_OK | MB_ICONERROR);
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
picojson::object obj = json.get<picojson::object>();
|
||||||
|
std::string msg, sts;
|
||||||
|
if (auto search = obj.find("message"); search != obj.end()) {
|
||||||
|
msg = (search->first) + ": " + (search->second).get<std::string>();
|
||||||
|
}
|
||||||
|
if (auto search = obj.find("status"); search != obj.end()) {
|
||||||
|
sts = (search->first) + ": " + (search->second).get<std::string>();
|
||||||
|
}
|
||||||
|
logger.Out(L"[UPDT] %s(%d): Error! %s", TEXT(__FUNCTION__), __LINE__, ConvertUtf8ToWide(msg + ", " + sts).c_str());
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
err = GetLastError();
|
err = GetLastError();
|
||||||
|
|||||||
Reference in New Issue
Block a user