libweave: Improve VLOG(1) for cloud request Cloud request/responses were already logged in buffet when log level 1 was set. However it is still difficult to track request-response pairs when OAuth2 requests were made when refreshing access tokens. Made sure we log the request ID of refresh access token and also when we receive success/error response, log the matching request ID to match it with the corresponding request. BUG=None TEST=`FEATURES=test emerge-link libchromeos` Change-Id: Icaad22b4b37adf85cbe937e5b4d5adc58d56706a Reviewed-on: https://chromium-review.googlesource.com/285745 Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org> Tested-by: Alex Vakulenko <avakulenko@chromium.org> Reviewed-by: Vitaly Buka <vitalybuka@chromium.org> Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/libweave/src/device_registration_info.cc b/libweave/src/device_registration_info.cc index 8b1dca1..4671010 100644 --- a/libweave/src/device_registration_info.cc +++ b/libweave/src/device_registration_info.cc
@@ -212,7 +212,7 @@ chromeos::ErrorPtr* error) const { const bool have_credentials = HaveRegistrationCredentials(); - VLOG(1) << "Device registration record " + VLOG(2) << "Device registration record " << ((have_credentials) ? "found" : "not found."); if (!have_credentials) chromeos::Error::AddTo(error, FROM_HERE, kErrorDomainGCD, @@ -265,6 +265,7 @@ auto on_refresh_error = [shared_error_callback]( chromeos::http::RequestID id, const chromeos::Error* error) { + VLOG(1) << "Refresh access token request with ID " << id << " failed"; shared_error_callback->Run(error); }; @@ -275,12 +276,14 @@ {"grant_type", "refresh_token"}, }; - chromeos::http::PostFormData( + chromeos::http::RequestID request_id = chromeos::http::PostFormData( GetOAuthURL("token"), form_data, {}, transport_, base::Bind(&DeviceRegistrationInfo::OnRefreshAccessTokenSuccess, weak_factory_.GetWeakPtr(), success_callback, shared_error_callback), base::Bind(on_refresh_error)); + VLOG(1) << "Refresh access token request dispatched. Request ID = " + << request_id; } void DeviceRegistrationInfo::OnRefreshAccessTokenSuccess( @@ -288,6 +291,7 @@ const std::shared_ptr<CloudRequestErrorCallback>& error_callback, chromeos::http::RequestID id, std::unique_ptr<chromeos::http::Response> response) { + VLOG(1) << "Refresh access token request with ID " << id << " completed"; chromeos::ErrorPtr error; auto json = ParseOAuthResponse(response.get(), &error); if (!json) { @@ -845,7 +849,7 @@ const base::DictionaryValue& json) { const base::ListValue* commands{nullptr}; if (!json.GetList("commands", &commands)) { - VLOG(1) << "No commands in the response."; + VLOG(2) << "No commands in the response."; } const base::ListValue empty; callback.Run(commands ? *commands : empty);