diff options
author | Alexander Tkachev | 2016-07-23 12:52:27 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 15c6772ff7638e104027f7b7777180e6191841fc (patch) | |
tree | 7887ce51ef6c3d6fd7ab574aa0e7da85d47067f8 | |
parent | d57e0c89b5b20dac247cb2f43450014d84719ba6 (diff) | |
download | scummvm-rg350-15c6772ff7638e104027f7b7777180e6191841fc.tar.gz scummvm-rg350-15c6772ff7638e104027f7b7777180e6191841fc.tar.bz2 scummvm-rg350-15c6772ff7638e104027f7b7777180e6191841fc.zip |
ALL: Fix debug, warning and error usage
Added prefixes, used debug(9).
28 files changed, 111 insertions, 109 deletions
diff --git a/backends/cloud/box/boxstorage.cpp b/backends/cloud/box/boxstorage.cpp index 401ec6a115..c2c4c6278e 100644 --- a/backends/cloud/box/boxstorage.cpp +++ b/backends/cloud/box/boxstorage.cpp @@ -115,8 +115,8 @@ void BoxStorage::tokenRefreshed(BoolCallback callback, Networking::JsonResponse Common::JSONObject result = json->asObject(); if (!result.contains("access_token") || !result.contains("refresh_token")) { - warning("Bad response, no token passed"); - debug("%s", json->stringify().c_str()); + warning("BoxStorage: bad response, no token passed"); + debug(9, "%s", json->stringify().c_str()); if (callback) (*callback)(BoolResponse(nullptr, false)); } else { @@ -141,8 +141,8 @@ void BoxStorage::codeFlowComplete(BoolResponse response) { } void BoxStorage::codeFlowFailed(Networking::ErrorResponse error) { - debug("Box's code flow failed (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); - debug("%s", error.response.c_str()); + debug(9, "BoxStorage: code flow failed (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); + debug(9, "%s", error.response.c_str()); CloudMan.removeStorage(this); } @@ -158,7 +158,7 @@ Common::String BoxStorage::name() const { void BoxStorage::infoInnerCallback(StorageInfoCallback outerCallback, Networking::JsonResponse response) { Common::JSONValue *json = response.value; if (!json) { - warning("NULL passed instead of JSON"); + warning("BoxStorage::infoInnerCallback: NULL passed instead of JSON"); delete outerCallback; return; } @@ -210,7 +210,7 @@ Networking::Request *BoxStorage::listDirectoryById(Common::String id, ListDirect void BoxStorage::createDirectoryInnerCallback(BoolCallback outerCallback, Networking::JsonResponse response) { Common::JSONValue *json = response.value; if (!json) { - warning("NULL passed instead of JSON"); + warning("BoxStorage::createDirectoryInnerCallback: NULL passed instead of JSON"); delete outerCallback; return; } @@ -292,12 +292,12 @@ BoxStorage *BoxStorage::loadFromConfig(Common::String keyPrefix) { loadKeyAndSecret(); if (!ConfMan.hasKey(keyPrefix + "access_token", ConfMan.kCloudDomain)) { - warning("No access_token found"); + warning("BoxStorage: no access_token found"); return nullptr; } if (!ConfMan.hasKey(keyPrefix + "refresh_token", ConfMan.kCloudDomain)) { - warning("No refresh_token found"); + warning("BoxStorage: no refresh_token found"); return nullptr; } diff --git a/backends/cloud/box/boxtokenrefresher.cpp b/backends/cloud/box/boxtokenrefresher.cpp index 65964f3010..c798b97343 100644 --- a/backends/cloud/box/boxtokenrefresher.cpp +++ b/backends/cloud/box/boxtokenrefresher.cpp @@ -69,7 +69,7 @@ void BoxTokenRefresher::finishJson(Common::JSONValue *json) { long httpCode = -1; if (_stream) { httpCode = _stream->httpResponseCode(); - debug(9, "code %ld", httpCode); + debug(9, "BoxTokenRefresher: code %ld", httpCode); } bool irrecoverable = true; @@ -77,12 +77,12 @@ void BoxTokenRefresher::finishJson(Common::JSONValue *json) { Common::String code, message; if (result.contains("code")) { code = result.getVal("code")->asString(); - debug(9, "code = %s", code.c_str()); + debug(9, "BoxTokenRefresher: code = %s", code.c_str()); } if (result.contains("message")) { message = result.getVal("message")->asString(); - debug(9, "message = %s", message.c_str()); + debug(9, "BoxTokenRefresher: message = %s", message.c_str()); } //TODO: decide when token refreshment will help diff --git a/backends/cloud/box/boxuploadrequest.cpp b/backends/cloud/box/boxuploadrequest.cpp index 29034c479f..f68ba6a580 100644 --- a/backends/cloud/box/boxuploadrequest.cpp +++ b/backends/cloud/box/boxuploadrequest.cpp @@ -143,8 +143,9 @@ void BoxUploadRequest::uploadedCallback(Networking::JsonResponse response) { } if (error.httpResponseCode != 200 && error.httpResponseCode != 201) - warning("looks like an error"); + warning("BoxUploadRequest: looks like an error (bad HTTP code)"); + //TODO: add more JSON warnings there Common::JSONValue *json = response.value; if (json) { if (json->isObject()) { @@ -188,10 +189,10 @@ void BoxUploadRequest::uploadedCallback(Networking::JsonResponse response) { */ } - warning("no file info to return"); + warning("BoxUploadRequest: no file info to return"); finishUpload(StorageFile(_savePath, 0, 0, false)); } else { - warning("null, not json"); + warning("BoxUploadRequest: null, not json"); finishError(error); } diff --git a/backends/cloud/downloadrequest.cpp b/backends/cloud/downloadrequest.cpp index f706ed64f4..e28670fc7b 100644 --- a/backends/cloud/downloadrequest.cpp +++ b/backends/cloud/downloadrequest.cpp @@ -99,8 +99,10 @@ void DownloadRequest::handle() { if (_remoteFileStream->eos()) { if (_remoteFileStream->httpResponseCode() != 200) { - warning("HTTP response code is not 200 OK (it's %ld)", _remoteFileStream->httpResponseCode()); + warning("DownloadRequest: HTTP response code is not 200 OK (it's %ld)", _remoteFileStream->httpResponseCode()); //TODO: do something about it actually + // the problem is file's already downloaded, stream is over + // so we can't return error message anymore } finishDownload(_remoteFileStream->httpResponseCode() == 200); diff --git a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp index ad9b0fcc0d..6cc6801bc0 100644 --- a/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp +++ b/backends/cloud/dropbox/dropboxcreatedirectoryrequest.cpp @@ -80,7 +80,7 @@ void DropboxCreateDirectoryRequest::responseCallback(Networking::JsonResponse re error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); if (!json) { - warning("NULL passed instead of JSON"); + warning("DropboxCreateDirectoryRequest: NULL passed instead of JSON"); finishError(error); return; } diff --git a/backends/cloud/dropbox/dropboxinforequest.cpp b/backends/cloud/dropbox/dropboxinforequest.cpp index 207c20271a..c5cbb9d917 100644 --- a/backends/cloud/dropbox/dropboxinforequest.cpp +++ b/backends/cloud/dropbox/dropboxinforequest.cpp @@ -77,7 +77,7 @@ void DropboxInfoRequest::userResponseCallback(Networking::JsonResponse response) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); if (!json) { - warning("NULL passed instead of JSON"); + warning("DropboxInfoRequest: NULL passed instead of JSON"); finishError(error); return; } @@ -115,7 +115,7 @@ void DropboxInfoRequest::quotaResponseCallback(Networking::JsonResponse response error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); if (!json) { - warning("NULL passed instead of JSON"); + warning("DropboxInfoRequest: NULL passed instead of JSON"); finishError(error); return; } diff --git a/backends/cloud/dropbox/dropboxstorage.cpp b/backends/cloud/dropbox/dropboxstorage.cpp index 20f8a68327..6fd1f9d2fd 100644 --- a/backends/cloud/dropbox/dropboxstorage.cpp +++ b/backends/cloud/dropbox/dropboxstorage.cpp @@ -86,8 +86,8 @@ void DropboxStorage::codeFlowComplete(Networking::JsonResponse response) { if (json) { Common::JSONObject result = json->asObject(); if (!result.contains("access_token") || !result.contains("uid")) { - warning("%s", json->stringify(true).c_str()); - warning("Bad response, no token/uid passed"); + warning("DropboxStorage: bad response, no token/uid passed"); + debug(9, "%s", json->stringify(true).c_str()); CloudMan.removeStorage(this); } else { _token = result.getVal("access_token")->asString(); @@ -99,14 +99,14 @@ void DropboxStorage::codeFlowComplete(Networking::JsonResponse response) { delete json; } else { - debug("DropboxStorage::codeFlowComplete: got NULL instead of JSON!"); + debug(9, "DropboxStorage::codeFlowComplete: got NULL instead of JSON!"); CloudMan.removeStorage(this); } } void DropboxStorage::codeFlowFailed(Networking::ErrorResponse error) { - debug("Dropbox's code flow failed (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); - debug("%s", error.response.c_str()); + debug(9, "DropboxStorage: code flow failed (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); + debug(9, "%s", error.response.c_str()); CloudMan.removeStorage(this); } @@ -161,12 +161,12 @@ DropboxStorage *DropboxStorage::loadFromConfig(Common::String keyPrefix) { loadKeyAndSecret(); if (!ConfMan.hasKey(keyPrefix + "access_token", ConfMan.kCloudDomain)) { - warning("No access_token found"); + warning("DropboxStorage: no access_token found"); return nullptr; } if (!ConfMan.hasKey(keyPrefix + "user_id", ConfMan.kCloudDomain)) { - warning("No user_id found"); + warning("DropboxStorage: no user_id found"); return nullptr; } diff --git a/backends/cloud/dropbox/dropboxuploadrequest.cpp b/backends/cloud/dropbox/dropboxuploadrequest.cpp index f129eaa94d..dd3a381b7a 100644 --- a/backends/cloud/dropbox/dropboxuploadrequest.cpp +++ b/backends/cloud/dropbox/dropboxuploadrequest.cpp @@ -123,7 +123,6 @@ void DropboxUploadRequest::uploadNextPart() { } void DropboxUploadRequest::partUploadedCallback(Networking::JsonResponse response) { - debug(9, "partUploadedCallback"); _workingRequest = nullptr; if (_ignoreCallback) return; @@ -133,6 +132,7 @@ void DropboxUploadRequest::partUploadedCallback(Networking::JsonResponse respons if (rq && rq->getNetworkReadStream()) error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); + // TODO: add more JSON-related warnings Common::JSONValue *json = response.value; if (json) { bool needsFinishRequest = false; @@ -140,7 +140,7 @@ void DropboxUploadRequest::partUploadedCallback(Networking::JsonResponse respons if (json->isObject()) { Common::JSONObject object = json->asObject(); - //debug("%s", json->stringify(true).c_str()); + //debug(9, "%s", json->stringify(true).c_str()); if (object.contains("error") || object.contains("error_summary")) { warning("Dropbox returned error: %s", object.getVal("error_summary")->asString().c_str()); @@ -163,19 +163,19 @@ void DropboxUploadRequest::partUploadedCallback(Networking::JsonResponse respons if (object.contains("session_id")) _sessionId = object.getVal("session_id")->asString(); else - warning("no session_id found in Dropbox's response"); + warning("DropboxUploadRequest: no session_id found"); needsFinishRequest = true; } } if (!needsFinishRequest && (_contentsStream->eos() || _contentsStream->pos() >= _contentsStream->size() - 1)) { - warning("no file info to return"); + warning("DropboxUploadRequest: no file info to return"); finishUpload(StorageFile(_savePath, 0, 0, false)); } else { uploadNextPart(); } } else { - warning("null, not json"); + warning("DropboxUploadRequest: null, not json"); finishError(error); } @@ -183,7 +183,6 @@ void DropboxUploadRequest::partUploadedCallback(Networking::JsonResponse respons } void DropboxUploadRequest::partUploadedErrorCallback(Networking::ErrorResponse error) { - debug("partUploadedErrorCallback"); _workingRequest = nullptr; if (_ignoreCallback) return; diff --git a/backends/cloud/folderdownloadrequest.cpp b/backends/cloud/folderdownloadrequest.cpp index fe9704cf81..7eeee0c6d6 100644 --- a/backends/cloud/folderdownloadrequest.cpp +++ b/backends/cloud/folderdownloadrequest.cpp @@ -129,7 +129,7 @@ void FolderDownloadRequest::downloadNextFile() { if (_remoteDirectoryPath != "" && (_remoteDirectoryPath.lastChar() != '/' && _remoteDirectoryPath.lastChar() != '\\')) localPath.erase(0, 1); } else { - warning("Can't process the following paths:"); + warning("FolderDownloadRequest: Can't process the following paths:"); warning("remote directory: %s", _remoteDirectoryPath.c_str()); warning("remote file under that directory: %s", remotePath.c_str()); } @@ -139,7 +139,7 @@ void FolderDownloadRequest::downloadNextFile() { else localPath = _localDirectoryPath + "/" + localPath; } - debug(9, "%s -> %s", remotePath.c_str(), localPath.c_str()); + debug(9, "FolderDownloadRequest: %s -> %s", remotePath.c_str(), localPath.c_str()); _workingRequest = _storage->downloadById( _currentFile.id(), localPath, new Common::Callback<FolderDownloadRequest, Storage::BoolResponse>(this, &FolderDownloadRequest::fileDownloadedCallback), diff --git a/backends/cloud/googledrive/googledrivestorage.cpp b/backends/cloud/googledrive/googledrivestorage.cpp index af19019a1e..7ae9dde3bd 100644 --- a/backends/cloud/googledrive/googledrivestorage.cpp +++ b/backends/cloud/googledrive/googledrivestorage.cpp @@ -113,14 +113,14 @@ void GoogleDriveStorage::tokenRefreshed(BoolCallback callback, Networking::JsonR Common::JSONObject result = json->asObject(); if (!result.contains("access_token")) { - warning("Bad response, no token passed"); - debug("%s", json->stringify().c_str()); + warning("GoogleDriveStorage: bad response, no token passed"); + debug(9, "%s", json->stringify().c_str()); if (callback) (*callback)(BoolResponse(nullptr, false)); } else { _token = result.getVal("access_token")->asString(); if (!result.contains("refresh_token")) - warning("No refresh_token passed"); + warning("GoogleDriveStorage: no refresh_token passed"); else _refreshToken = result.getVal("refresh_token")->asString(); CloudMan.save(); //ask CloudManager to save our new refreshToken @@ -143,8 +143,8 @@ void GoogleDriveStorage::codeFlowComplete(BoolResponse response) { } void GoogleDriveStorage::codeFlowFailed(Networking::ErrorResponse error) { - debug("Google Drive's code flow failed (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); - debug("%s", error.response.c_str()); + debug(9, "GoogleDriveStorage: code flow failed (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); + debug(9, "%s", error.response.c_str()); CloudMan.removeStorage(this); } @@ -160,7 +160,7 @@ Common::String GoogleDriveStorage::name() const { void GoogleDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Networking::JsonResponse response) { Common::JSONValue *json = response.value; if (!json) { - warning("NULL passed instead of JSON"); + warning("GoogleDriveStorage: NULL passed instead of JSON"); delete outerCallback; return; } @@ -201,7 +201,7 @@ void GoogleDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Ne void GoogleDriveStorage::createDirectoryInnerCallback(BoolCallback outerCallback, Networking::JsonResponse response) { Common::JSONValue *json = response.value; if (!json) { - warning("NULL passed instead of JSON"); + warning("GoogleDriveStorage: NULL passed instead of JSON"); delete outerCallback; return; } @@ -241,7 +241,7 @@ Networking::Request *GoogleDriveStorage::streamFileById(Common::String id, Netwo } void GoogleDriveStorage::printInfo(StorageInfoResponse response) { - debug(9, "\nuser info:"); + debug(9, "\nGoogleDriveStorage: user info:"); debug(9, "\tname: %s", response.value.name().c_str()); debug(9, "\temail: %s", response.value.email().c_str()); debug(9, "\tdisk usage: %lu/%lu", response.value.used(), response.value.available()); @@ -286,12 +286,12 @@ GoogleDriveStorage *GoogleDriveStorage::loadFromConfig(Common::String keyPrefix) loadKeyAndSecret(); if (!ConfMan.hasKey(keyPrefix + "access_token", ConfMan.kCloudDomain)) { - warning("No access_token found"); + warning("GoogleDriveStorage: no access_token found"); return nullptr; } if (!ConfMan.hasKey(keyPrefix + "refresh_token", ConfMan.kCloudDomain)) { - warning("No refresh_token found"); + warning("GoogleDriveStorage: no refresh_token found"); return nullptr; } diff --git a/backends/cloud/googledrive/googledrivetokenrefresher.cpp b/backends/cloud/googledrive/googledrivetokenrefresher.cpp index 1b858504c5..99661c262e 100644 --- a/backends/cloud/googledrive/googledrivetokenrefresher.cpp +++ b/backends/cloud/googledrive/googledrivetokenrefresher.cpp @@ -69,7 +69,7 @@ void GoogleDriveTokenRefresher::finishJson(Common::JSONValue *json) { //new token needed => request token & then retry original request if (_stream) { httpResponseCode = _stream->httpResponseCode(); - debug(9, "code %ld", httpResponseCode); + debug(9, "GoogleDriveTokenRefresher: code = %ld", httpResponseCode); } Common::JSONObject error = result.getVal("error")->asObject(); @@ -79,12 +79,12 @@ void GoogleDriveTokenRefresher::finishJson(Common::JSONValue *json) { Common::String message; if (error.contains("code") && error.getVal("code")->isIntegerNumber()) { code = error.getVal("code")->asIntegerNumber(); - debug(9, "code = %u", code); + debug(9, "GoogleDriveTokenRefresher: code = %u", code); } if (error.contains("message")) { message = error.getVal("message")->asString(); - debug(9, "message = %s", message.c_str()); + debug(9, "GoogleDriveTokenRefresher: message = %s", message.c_str()); } if (code == 401 || message == "Invalid Credentials") diff --git a/backends/cloud/googledrive/googledriveuploadrequest.cpp b/backends/cloud/googledrive/googledriveuploadrequest.cpp index bd9d8790ed..14f43eecde 100644 --- a/backends/cloud/googledrive/googledriveuploadrequest.cpp +++ b/backends/cloud/googledrive/googledriveuploadrequest.cpp @@ -305,13 +305,13 @@ void GoogleDriveUploadRequest::partUploadedCallback(Networking::JsonResponse res } if (_contentsStream->eos() || _contentsStream->pos() >= _contentsStream->size() - 1) { - warning("no file info to return"); + warning("GoogleDriveUploadRequest: no file info to return"); finishUpload(StorageFile(_savePath, 0, 0, false)); } else { uploadNextPart(); } } else { - warning("null, not json"); + warning("GoogleDriveUploadRequest: null, not json"); finishError(error); } diff --git a/backends/cloud/id/idresolveidrequest.cpp b/backends/cloud/id/idresolveidrequest.cpp index 6742a5890f..e8589fc204 100644 --- a/backends/cloud/id/idresolveidrequest.cpp +++ b/backends/cloud/id/idresolveidrequest.cpp @@ -70,16 +70,16 @@ void IdResolveIdRequest::listedDirectoryCallback(Storage::FileArrayResponse resp return; Common::String currentLevelName = _requestedPath; - ///debug("'%s'", currentLevelName.c_str()); + ///debug(9, "'%s'", currentLevelName.c_str()); if (_currentDirectory.size()) currentLevelName.erase(0, _currentDirectory.size()); if (currentLevelName.size() && (currentLevelName[0] == '/' || currentLevelName[0] == '\\')) currentLevelName.erase(0, 1); - ///debug("'%s'", currentLevelName.c_str()); + ///debug(9, "'%s'", currentLevelName.c_str()); for (uint32 i = 0; i < currentLevelName.size(); ++i) { if (currentLevelName[i] == '/' || currentLevelName[i] == '\\') { currentLevelName.erase(i); - ///debug("'%s'", currentLevelName.c_str()); + ///debug(9, "'%s'", currentLevelName.c_str()); break; } } @@ -90,7 +90,7 @@ void IdResolveIdRequest::listedDirectoryCallback(Storage::FileArrayResponse resp path += currentLevelName; bool lastLevel = (path.equalsIgnoreCase(_requestedPath)); - ///debug("so, searching for '%s' in '%s'", currentLevelName.c_str(), _currentDirectory.c_str()); + ///debug(9, "IdResolveIdRequest: searching for '%s' in '%s'", currentLevelName.c_str(), _currentDirectory.c_str()); Common::Array<StorageFile> &files = response.value; bool found = false; @@ -100,7 +100,7 @@ void IdResolveIdRequest::listedDirectoryCallback(Storage::FileArrayResponse resp _currentDirectory += "/"; _currentDirectory += files[i].name(); _currentDirectoryId = files[i].id(); - ///debug("found it! new directory and its id: '%s', '%s'", _currentDirectory.c_str(), _currentDirectoryId.c_str()); + ///debug(9, "IdResolveIdRequest: found it! new directory and its id: '%s', '%s'", _currentDirectory.c_str(), _currentDirectoryId.c_str()); listNextDirectory(files[i]); found = true; break; diff --git a/backends/cloud/id/idstorage.cpp b/backends/cloud/id/idstorage.cpp index 857e3fb379..36f2df642c 100644 --- a/backends/cloud/id/idstorage.cpp +++ b/backends/cloud/id/idstorage.cpp @@ -36,7 +36,7 @@ namespace Id { IdStorage::~IdStorage() {} void IdStorage::printFiles(FileArrayResponse response) { - debug(9, "files:"); + debug(9, "IdStorage: files:"); Common::Array<StorageFile> &files = response.value; for (uint32 i = 0; i < files.size(); ++i) { debug(9, "\t%s%s", files[i].name().c_str(), files[i].isDirectory() ? " (directory)" : ""); @@ -47,11 +47,11 @@ void IdStorage::printFiles(FileArrayResponse response) { } void IdStorage::printBool(BoolResponse response) { - debug(9, "bool: %s", response.value ? "true" : "false"); + debug(9, "IdStorage: bool: %s", response.value ? "true" : "false"); } void IdStorage::printFile(UploadResponse response) { - debug(9, "\nuploaded file info:"); + debug(9, "\nIdStorage: uploaded file info:"); debug(9, "\tid: %s", response.value.path().c_str()); debug(9, "\tname: %s", response.value.name().c_str()); debug(9, "\tsize: %u", response.value.size()); diff --git a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp index a31fd025ac..4d6d8fceda 100644 --- a/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp +++ b/backends/cloud/onedrive/onedrivecreatedirectoryrequest.cpp @@ -102,7 +102,7 @@ void OneDriveCreateDirectoryRequest::responseCallback(Networking::JsonResponse r error.httpResponseCode = rq->getNetworkReadStream()->httpResponseCode(); if (!json) { - warning("NULL passed instead of JSON"); + warning("OneDriveCreateDirectoryRequest: NULL passed instead of JSON"); finishError(error); return; } diff --git a/backends/cloud/onedrive/onedrivestorage.cpp b/backends/cloud/onedrive/onedrivestorage.cpp index af5d9f10ba..1008cab31f 100644 --- a/backends/cloud/onedrive/onedrivestorage.cpp +++ b/backends/cloud/onedrive/onedrivestorage.cpp @@ -113,8 +113,8 @@ void OneDriveStorage::tokenRefreshed(BoolCallback callback, Networking::JsonResp Common::JSONObject result = json->asObject(); if (!result.contains("access_token") || !result.contains("user_id") || !result.contains("refresh_token")) { - warning("Bad response, no token or user_id passed"); - debug("%s", json->stringify().c_str()); + warning("OneDriveStorage: bad response, no token or user_id passed"); + debug(9, "%s", json->stringify().c_str()); if (callback) (*callback)(BoolResponse(nullptr, false)); } else { @@ -141,8 +141,8 @@ void OneDriveStorage::codeFlowComplete(BoolResponse response) { } void OneDriveStorage::codeFlowFailed(Networking::ErrorResponse error) { - debug("OneDrive's code flow failed (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); - debug("%s", error.response.c_str()); + debug(9, "OneDriveStorage: code flow failed (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); + debug(9, "%s", error.response.c_str()); CloudMan.removeStorage(this); } @@ -159,7 +159,7 @@ Common::String OneDriveStorage::name() const { void OneDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Networking::JsonResponse response) { Common::JSONValue *json = response.value; if (!json) { - warning("NULL passed instead of JSON"); + warning("OneDriveStorage: NULL passed instead of JSON"); delete outerCallback; return; } @@ -199,7 +199,7 @@ void OneDriveStorage::infoInnerCallback(StorageInfoCallback outerCallback, Netwo void OneDriveStorage::fileInfoCallback(Networking::NetworkReadStreamCallback outerCallback, Networking::JsonResponse response) { if (!response.value) { - warning("fileInfoCallback: NULL"); + warning("OneDriveStorage::fileInfoCallback: NULL, not JSON"); if (outerCallback) (*outerCallback)(Networking::NetworkReadStreamResponse(response.request, nullptr)); return; @@ -214,8 +214,8 @@ void OneDriveStorage::fileInfoCallback(Networking::NetworkReadStreamCallback out new Networking::NetworkReadStream(url, nullptr, "") )); } else { - warning("downloadUrl not found in passed JSON"); - debug("%s", response.value->stringify().c_str()); + warning("OneDriveStorage: downloadUrl not found in passed JSON"); + debug(9, "%s", response.value->stringify().c_str()); if (outerCallback) (*outerCallback)(Networking::NetworkReadStreamResponse(response.request, nullptr)); } @@ -257,17 +257,17 @@ OneDriveStorage *OneDriveStorage::loadFromConfig(Common::String keyPrefix) { loadKeyAndSecret(); if (!ConfMan.hasKey(keyPrefix + "access_token", ConfMan.kCloudDomain)) { - warning("No access_token found"); + warning("OneDriveStorage: no access_token found"); return nullptr; } if (!ConfMan.hasKey(keyPrefix + "user_id", ConfMan.kCloudDomain)) { - warning("No user_id found"); + warning("OneDriveStorage: no user_id found"); return nullptr; } if (!ConfMan.hasKey(keyPrefix + "refresh_token", ConfMan.kCloudDomain)) { - warning("No refresh_token found"); + warning("OneDriveStorage: no refresh_token found"); return nullptr; } diff --git a/backends/cloud/onedrive/onedrivetokenrefresher.cpp b/backends/cloud/onedrive/onedrivetokenrefresher.cpp index f7597599c7..5e3bce96af 100644 --- a/backends/cloud/onedrive/onedrivetokenrefresher.cpp +++ b/backends/cloud/onedrive/onedrivetokenrefresher.cpp @@ -69,7 +69,7 @@ void OneDriveTokenRefresher::finishJson(Common::JSONValue *json) { //new token needed => request token & then retry original request if (_stream) { httpResponseCode = _stream->httpResponseCode(); - debug(9, "code %ld", httpResponseCode); + debug(9, "OneDriveTokenRefresher: code = %ld", httpResponseCode); } Common::JSONObject error = result.getVal("error")->asObject(); @@ -78,12 +78,12 @@ void OneDriveTokenRefresher::finishJson(Common::JSONValue *json) { Common::String code, message; if (error.contains("code")) { code = error.getVal("code")->asString(); - debug(9, "code = %s", code.c_str()); + debug(9, "OneDriveTokenRefresher: code = %s", code.c_str()); } if (error.contains("message")) { message = error.getVal("message")->asString(); - debug(9, "message = %s", message.c_str()); + debug(9, "OneDriveTokenRefresher: message = %s", message.c_str()); } //determine whether token refreshing would help in this situation diff --git a/backends/cloud/onedrive/onedriveuploadrequest.cpp b/backends/cloud/onedrive/onedriveuploadrequest.cpp index ef1507d1f2..172266ce2a 100644 --- a/backends/cloud/onedrive/onedriveuploadrequest.cpp +++ b/backends/cloud/onedrive/onedriveuploadrequest.cpp @@ -130,7 +130,7 @@ void OneDriveUploadRequest::partUploadedCallback(Networking::JsonResponse respon Common::JSONObject object = json->asObject(); if (object.contains("error")) { - warning("OneDrive returned error: %s", json->stringify(true).c_str()); + warning("OneDriveUploadRequest: error: %s", json->stringify(true).c_str()); error.response = json->stringify(true); finishError(error); delete json; @@ -150,18 +150,18 @@ void OneDriveUploadRequest::partUploadedCallback(Networking::JsonResponse respon if (object.contains("uploadUrl")) _uploadUrl = object.getVal("uploadUrl")->asString(); else - warning("no uploadUrl found in OneDrive's response"); + warning("OneDriveUploadRequest: no uploadUrl found"); } } if (_contentsStream->eos() || _contentsStream->pos() >= _contentsStream->size() - 1) { - warning("no file info to return"); + warning("OneDriveUploadRequest: no file info to return"); finishUpload(StorageFile(_savePath, 0, 0, false)); } else { uploadNextPart(); } } else { - warning("null, not json"); + warning("OneDriveUploadRequest: null, not json"); finishError(error); } diff --git a/backends/cloud/savessyncrequest.cpp b/backends/cloud/savessyncrequest.cpp index 7776804579..889c6b936b 100644 --- a/backends/cloud/savessyncrequest.cpp +++ b/backends/cloud/savessyncrequest.cpp @@ -125,11 +125,11 @@ void SavesSyncRequest::directoryListedCallback(Storage::ListDirectoryResponse re _filesToUpload.push_back(i->_key); } - debug(9, "\ndownload files:"); + debug(9, "\nSavesSyncRequest: download files:"); for (uint32 i = 0; i < _filesToDownload.size(); ++i) { debug(9, "%s", _filesToDownload[i].name().c_str()); } - debug(9, "\nupload files:"); + debug(9, "\nSavesSyncRequest: upload files:"); for (uint32 i = 0; i < _filesToUpload.size(); ++i) { debug(9, "%s", _filesToUpload[i].c_str()); } @@ -190,7 +190,7 @@ void SavesSyncRequest::directoryListedErrorCallback(Networking::ErrorResponse er Common::String dir = _storage->savesDirectoryPath(); if (dir.lastChar() == '/') dir.deleteLastChar(); - debug(9, "creating %s", dir.c_str()); + debug(9, "SavesSyncRequest: creating %s", dir.c_str()); _workingRequest = _storage->createDirectory( dir, new Common::Callback<SavesSyncRequest, Storage::BoolResponse>(this, &SavesSyncRequest::directoryCreatedCallback), @@ -238,7 +238,7 @@ void SavesSyncRequest::downloadNextFile() { sendCommand(GUI::kSavesSyncProgressCmd, (int)(getDownloadingProgress() * 100)); - debug(9, "downloading %s (%d %%)", _currentDownloadingFile.name().c_str(), (int)(getProgress() * 100)); + debug(9, "SavesSyncRequest: downloading %s (%d %%)", _currentDownloadingFile.name().c_str(), (int)(getProgress() * 100)); _workingRequest = _storage->downloadById( _currentDownloadingFile.id(), DefaultSaveFileManager::concatWithSavesPath(_currentDownloadingFile.name()), @@ -289,7 +289,7 @@ void SavesSyncRequest::uploadNextFile() { _currentUploadingFile = _filesToUpload.back(); _filesToUpload.pop_back(); - debug(9, "uploading %s (%d %%)", _currentUploadingFile.c_str(), (int)(getProgress() * 100)); + debug(9, "SavesSyncRequest: uploading %s (%d %%)", _currentUploadingFile.c_str(), (int)(getProgress() * 100)); if (_storage->uploadStreamSupported()) { _workingRequest = _storage->upload( _storage->savesDirectoryPath() + _currentUploadingFile, @@ -370,7 +370,7 @@ Common::Array<Common::String> SavesSyncRequest::getFilesToDownload() { } void SavesSyncRequest::finishError(Networking::ErrorResponse error) { - debug("SavesSync::finishError"); + debug(9, "SavesSync::finishError"); //if we were downloading a file - remember the name //and make the Request close() it, so we can delete it Common::String name = _currentDownloadingFile.name(); diff --git a/backends/cloud/storage.cpp b/backends/cloud/storage.cpp index b085401f47..910d80d153 100644 --- a/backends/cloud/storage.cpp +++ b/backends/cloud/storage.cpp @@ -42,8 +42,8 @@ Networking::ErrorCallback Storage::getErrorPrintingCallback() { } void Storage::printErrorResponse(Networking::ErrorResponse error) { - debug("error response (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); - debug("%s", error.response.c_str()); + debug(9, "Storage: error response (%s, %ld):", (error.failed ? "failed" : "interrupted"), error.httpResponseCode); + debug(9, "%s", error.response.c_str()); } Networking::Request *Storage::addRequest(Networking::Request *request) { diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp index 1d5fd0d0cb..f3dc91ad60 100644 --- a/backends/networking/curl/connectionmanager.cpp +++ b/backends/networking/curl/connectionmanager.cpp @@ -194,7 +194,7 @@ void ConnectionManager::processTransfers() { if (curlMsg->msg == CURLMSG_DONE) { debug(9, "ConnectionManager: SUCCESS (%d - %s)", curlMsg->data.result, curl_easy_strerror(curlMsg->data.result)); } else { - debug("ConnectionManager: FAILURE (CURLMsg (%d))", curlMsg->msg); + warning("ConnectionManager: FAILURE (CURLMsg (%d))", curlMsg->msg); } curl_multi_remove_handle(_multi, easyHandle); diff --git a/backends/networking/curl/curljsonrequest.cpp b/backends/networking/curl/curljsonrequest.cpp index 7db56cfdcc..aac89a1513 100644 --- a/backends/networking/curl/curljsonrequest.cpp +++ b/backends/networking/curl/curljsonrequest.cpp @@ -68,7 +68,7 @@ void CurlJsonRequest::handle() { uint32 readBytes = _stream->read(_buffer, CURL_JSON_REQUEST_BUFFER_SIZE); if (readBytes != 0) if (_contentsStream.write(_buffer, readBytes) != readBytes) - warning("MemoryWriteStreamDynamic was unable to write all the bytes"); + warning("CurlJsonRequest: unable to write all the bytes into MemoryWriteStreamDynamic"); if (_stream->eos()) { char *contents = getPreparedContents(); diff --git a/backends/networking/curl/curlrequest.cpp b/backends/networking/curl/curlrequest.cpp index 2d5bb1fa2b..64fa347023 100644 --- a/backends/networking/curl/curlrequest.cpp +++ b/backends/networking/curl/curlrequest.cpp @@ -52,7 +52,7 @@ void CurlRequest::handle() { if (_stream && _stream->eos()) { if (_stream->httpResponseCode() != 200) { - warning("HTTP response code is not 200 OK (it's %ld)", _stream->httpResponseCode()); + warning("CurlRequest: HTTP response code is not 200 OK (it's %ld)", _stream->httpResponseCode()); ErrorResponse error(this, false, true, "", _stream->httpResponseCode()); finishError(error); return; diff --git a/backends/networking/curl/networkreadstream.cpp b/backends/networking/curl/networkreadstream.cpp index 5c760d9e01..21f26895e9 100644 --- a/backends/networking/curl/networkreadstream.cpp +++ b/backends/networking/curl/networkreadstream.cpp @@ -129,7 +129,7 @@ void NetworkReadStream::init(const char *url, curl_slist *headersList, Common::H ); if (code != CURL_FORMADD_OK) - debug("field failed formadd"); + warning("NetworkReadStream: field curl_formadd('%s') failed", i->_key.c_str()); } for (Common::HashMap<Common::String, Common::String>::iterator i = formFiles.begin(); i != formFiles.end(); ++i) { @@ -142,7 +142,7 @@ void NetworkReadStream::init(const char *url, curl_slist *headersList, Common::H ); if (code != CURL_FORMADD_OK) - debug("file failed formadd"); + warning("NetworkReadStream: file curl_formadd('%s') failed", i->_key.c_str()); } curl_easy_setopt(_easy, CURLOPT_HTTPPOST, formpost); diff --git a/backends/networking/sdl_net/client.cpp b/backends/networking/sdl_net/client.cpp index 0026d0e346..dab38ba5c0 100644 --- a/backends/networking/sdl_net/client.cpp +++ b/backends/networking/sdl_net/client.cpp @@ -62,7 +62,7 @@ void Client::open(SDLNet_SocketSet set, TCPsocket socket) { if (set) { int numused = SDLNet_TCP_AddSocket(set, socket); if (numused == -1) { - error("SDLNet_AddSocket: %s\n", SDLNet_GetError()); + error("Client: SDLNet_AddSocket: %s\n", SDLNet_GetError()); } } } @@ -79,13 +79,13 @@ bool Client::readMoreIfNeeded() { int bytes = SDLNet_TCP_Recv(_socket, _buffer, CLIENT_BUFFER_SIZE); if (bytes <= 0) { - warning("Client::readHeaders recv fail"); + warning("Client::readMoreIfNeeded: recv fail"); close(); return false; } if (_stream->write(_buffer, bytes) != bytes) { - warning("failed to write() into MemoryReadWriteStream"); + warning("Client::readMoreIfNeeded: failed to write() into MemoryReadWriteStream"); close(); return false; } @@ -146,7 +146,7 @@ void Client::close() { if (_socket) { int numused = SDLNet_TCP_DelSocket(_set, _socket); if (numused == -1) - error("SDLNet_DelSocket: %s\n", SDLNet_GetError()); + error("Client: SDLNet_DelSocket: %s\n", SDLNet_GetError()); } _set = nullptr; } diff --git a/backends/networking/sdl_net/localwebserver.cpp b/backends/networking/sdl_net/localwebserver.cpp index 75dbea0d56..8a40aed697 100644 --- a/backends/networking/sdl_net/localwebserver.cpp +++ b/backends/networking/sdl_net/localwebserver.cpp @@ -96,14 +96,14 @@ void LocalWebserver::start() { // Create a listening TCP socket IPaddress ip; if (SDLNet_ResolveHost(&ip, NULL, _serverPort) == -1) { - error("SDLNet_ResolveHost: %s\n", SDLNet_GetError()); + error("LocalWebserver: SDLNet_ResolveHost: %s\n", SDLNet_GetError()); } resolveAddress(&ip); _serverSocket = SDLNet_TCP_Open(&ip); if (!_serverSocket) { - warning("SDLNet_TCP_Open: %s", SDLNet_GetError()); + warning("LocalWebserver: SDLNet_TCP_Open: %s", SDLNet_GetError()); stopTimer(); g_system->displayMessageOnOSD(_("Failed to start local webserver.\nCheck whether selected port is not used by another application and try again.")); _handleMutex.unlock(); @@ -113,12 +113,12 @@ void LocalWebserver::start() { // Create a socket set _set = SDLNet_AllocSocketSet(MAX_CONNECTIONS + 1); //one more for our server socket if (!_set) { - error("SDLNet_AllocSocketSet: %s\n", SDLNet_GetError()); + error("LocalWebserver: SDLNet_AllocSocketSet: %s\n", SDLNet_GetError()); } int numused = SDLNet_TCP_AddSocket(_set, _serverSocket); if (numused == -1) { - error("SDLNet_AddSocket: %s\n", SDLNet_GetError()); + error("LocalWebserver: SDLNet_AddSocket: %s\n", SDLNet_GetError()); } _handleMutex.unlock(); } @@ -183,7 +183,7 @@ void LocalWebserver::handle() { _handleMutex.lock(); int numready = SDLNet_CheckSockets(_set, 0); if (numready == -1) { - error("SDLNet_CheckSockets: %s\n", SDLNet_GetError()); + error("LocalWebserver: SDLNet_CheckSockets: %s\n", SDLNet_GetError()); } else if (numready) { acceptClient(); } @@ -268,11 +268,11 @@ void LocalWebserver::resolveAddress(void *ipAddress) { // default way (might work everywhere, surely works on Windows) const char *name = SDLNet_ResolveIP(ip); if (name == NULL) { - warning("SDLNet_ResolveHost: %s\n", SDLNet_GetError()); + warning("LocalWebserver: SDLNet_ResolveHost: %s\n", SDLNet_GetError()); } else { IPaddress localIp; if (SDLNet_ResolveHost(&localIp, name, _serverPort) == -1) { - warning("SDLNet_ResolveHost: %s\n", SDLNet_GetError()); + warning("LocalWebserver: SDLNet_ResolveHost: %s\n", SDLNet_GetError()); } else { _address = Common::String::format( "http://%u.%u.%u.%u:%u/", @@ -284,7 +284,7 @@ void LocalWebserver::resolveAddress(void *ipAddress) { // check that our trick worked if (_address.contains("/127.0.0.1:") || _address.contains("localhost") || _address.contains("/0.0.0.0:")) - warning("Failed to resolve IP with the default way"); + warning("LocalWebserver: Failed to resolve IP with the default way"); else return; @@ -307,7 +307,7 @@ void LocalWebserver::resolveAddress(void *ipAddress) { tmpAddrPtr = &((struct sockaddr_in *)i->ifa_addr)->sin_addr; char addressBuffer[INET_ADDRSTRLEN]; inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN); - debug("%s IP Address %s", i->ifa_name, addressBuffer); + debug(9, "%s IP Address %s", i->ifa_name, addressBuffer); addr = addressBuffer; } @@ -317,7 +317,7 @@ void LocalWebserver::resolveAddress(void *ipAddress) { tmpAddrPtr = &((struct sockaddr_in6 *)i->ifa_addr)->sin6_addr; char addressBuffer[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN); - debug("%s IP Address %s", i->ifa_name, addressBuffer); + debug(9, "%s IP Address %s", i->ifa_name, addressBuffer); addr = addressBuffer; } */ diff --git a/backends/networking/sdl_net/reader.cpp b/backends/networking/sdl_net/reader.cpp index 828f583003..0e4cc9a106 100644 --- a/backends/networking/sdl_net/reader.cpp +++ b/backends/networking/sdl_net/reader.cpp @@ -138,7 +138,7 @@ void readFromThatUntilLineEnd(const char *cstr, Common::String needle, Common::S void Reader::handleFirstHeaders(Common::String headers) { if (!_boundary.empty()) { - warning("handleFirstHeaders() called when first headers were already handled"); + warning("Reader: handleFirstHeaders() called when first headers were already handled"); return; } @@ -252,7 +252,7 @@ void Reader::parseQueryParameters() { } else { if (_query[i] == '&') { if (_queryParameters.contains(key)) - warning("Query parameter \"%s\" is already set!", key.c_str()); + warning("Reader: query parameter \"%s\" is already set!", key.c_str()); else _queryParameters[key] = LocalWebserver::urlDecode(value); readingKey = true; @@ -265,7 +265,7 @@ void Reader::parseQueryParameters() { if (!key.empty()) { if (_queryParameters.contains(key)) - warning("Query parameter \"%s\" is already set!", key.c_str()); + warning("Reader: query parameter \"%s\" is already set!", key.c_str()); else _queryParameters[key] = LocalWebserver::urlDecode(value); } @@ -410,9 +410,9 @@ bool Reader::readBlockContent(Common::WriteStream *stream) { if (bts == "--") _allContentRead = true; else if (bts != "\r\n") - warning("strange bytes: \"%s\"", bts.c_str()); + warning("Reader: strange bytes: \"%s\"", bts.c_str()); } else { - warning("strange ending"); + warning("Reader: strange ending"); _allContentRead = true; } diff --git a/gui/options.cpp b/gui/options.cpp index 603fc23eea..f2ae946ff9 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -1950,8 +1950,8 @@ void GlobalOptionsDialog::storageListDirectoryCallback(Cloud::Storage::ListDirec } void GlobalOptionsDialog::storageErrorCallback(Networking::ErrorResponse response) { - debug("error response (%s, %ld):", (response.failed ? "failed" : "interrupted"), response.httpResponseCode); - debug("%s", response.response.c_str()); + debug(9, "GlobalOptionsDialog: error response (%s, %ld):", (response.failed ? "failed" : "interrupted"), response.httpResponseCode); + debug(9, "%s", response.response.c_str()); if (!response.interrupted) g_system->displayMessageOnOSD(_("Request failed.\nCheck your Internet connection.")); |