From f4f82e32a39804d6f356aa30310544c8cf53db93 Mon Sep 17 00:00:00 2001 From: Alex Vakulenko Date: Tue, 8 Sep 2015 14:57:51 -0700 Subject: Improve default logging when sending asynchronous HTTP requests When analyzing production logs (with log level = 0/INFO) it is difficult to judge when HTTP request succeed or fail. With --v=2 enabled, all of this is provided, but this is not good for production devices and their logs. Added request/response tracking messages to LOG(INFO) level to make log analysis easier. BUG: 23791756 Change-Id: Ie3bf48d45d6facb02a6d26176d10a5612d4e683b --- chromeos/http/http_transport_curl.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/chromeos/http/http_transport_curl.cc b/chromeos/http/http_transport_curl.cc index 5a3e207..4bc6208 100644 --- a/chromeos/http/http_transport_curl.cc +++ b/chromeos/http/http_transport_curl.cc @@ -246,7 +246,7 @@ RequestID Transport::StartAsyncTransfer(http::Connection* connection, request_id_map_.erase(request_id); return 0; } - VLOG(1) << "Started asynchronous HTTP request with ID " << request_id; + LOG(INFO) << "Started asynchronous HTTP request with ID " << request_id; return request_id; } @@ -258,7 +258,7 @@ bool Transport::CancelRequest(RequestID request_id) { LOG(WARNING) << "HTTP request #" << request_id << " not found"; return false; } - VLOG(1) << "Canceling HTTP request #" << request_id; + LOG(INFO) << "Canceling HTTP request #" << request_id; CleanAsyncConnection(p->second); return true; } @@ -446,8 +446,9 @@ void Transport::OnTransferComplete(Connection* connection, CURLcode code) { auto p = async_requests_.find(connection); CHECK(p != async_requests_.end()) << "Unknown connection"; AsyncRequestData* request_data = p->second.get(); - VLOG(1) << "HTTP request # " << request_data->request_id << " has completed " - << (code == CURLE_OK ? "successfully" : "with an error"); + LOG(INFO) << "HTTP request # " << request_data->request_id + << " has completed " + << (code == CURLE_OK ? "successfully" : "with an error"); if (code != CURLE_OK) { chromeos::ErrorPtr error; AddEasyCurlError(&error, FROM_HERE, code, curl_interface_.get()); @@ -456,6 +457,8 @@ void Transport::OnTransferComplete(Connection* connection, CURLcode code) { p->second->request_id, base::Owned(error.release()))); } else { + LOG(INFO) << "Response: " << connection->GetResponseStatusCode() << " (" + << connection->GetResponseStatusText() << ")"; chromeos::ErrorPtr error; // Rewind the response data stream to the beginning so the clients can // read the data back. -- cgit v1.2.3