Added auth extended logging

This commit is contained in:
r.kuznetsov 2018-05-14 17:28:10 +03:00 committed by Aleksandr Zatsepin
parent a08544edee
commit 887cff0274
2 changed files with 7 additions and 6 deletions

View file

@ -294,8 +294,9 @@ void User::Authenticate(std::string const & socialToken, SocialTokenType socialT
{
SetAccessToken(ParseAccessToken(response));
FinishAuthentication();
}, [this](int)
}, [this](int code, std::string const & response)
{
LOG(LWARNING, ("Authentication failed. Code =", code, "Response =", response));
FinishAuthentication();
});
});
@ -422,12 +423,12 @@ void User::UploadUserReviews(std::string && dataStr, size_t numberOfUnsynchroniz
if (onCompleteUploading != nullptr)
onCompleteUploading(true /* isSuccessful */);
},
[onCompleteUploading, numberOfUnsynchronized](int errorCode)
[onCompleteUploading, numberOfUnsynchronized](int errorCode, std::string const & response)
{
alohalytics::Stats::Instance().LogEvent("UGC_DataUpload_error",
{{"error", strings::to_string(errorCode)},
{"num", strings::to_string(numberOfUnsynchronized)}});
LOG(LWARNING, ("Reviews have not been uploaded. Code =", errorCode));
LOG(LWARNING, ("Reviews have not been uploaded. Code =", errorCode, "Response =", response));
if (onCompleteUploading != nullptr)
onCompleteUploading(false /* isSuccessful */);
@ -498,7 +499,7 @@ void User::RequestImpl(std::string const & url, BuildRequestHandler const & onBu
ResetAccessToken();
LOG(LWARNING, ("Access denied for", url));
if (onError)
onError(resultCode);
onError(resultCode, request.ServerResponse());
return;
}
}
@ -512,7 +513,7 @@ void User::RequestImpl(std::string const & url, BuildRequestHandler const & onBu
attemptIndex++;
if (!isSuccessfulCode && attemptIndex == kMaxAttemptsCount && onError)
onError(resultCode);
onError(resultCode, request.ServerResponse());
if (attemptIndex < kMaxAttemptsCount)
{

View file

@ -46,7 +46,7 @@ public:
using BuildRequestHandler = std::function<void(platform::HttpClient &)>;
using SuccessHandler = std::function<void(std::string const &)>;
using ErrorHandler = std::function<void(int)>;
using ErrorHandler = std::function<void(int, std::string const & response)>;
using CompleteUploadingHandler = std::function<void(bool)>;
User();