Skip to content

Commit 3a19d8f

Browse files
committed
Verbose logging for http message
1 parent d08bf70 commit 3a19d8f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/AppInstallerRepositoryCore/Rest/Schema/HttpClientHelper.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace AppInstaller::Repository::Rest::Schema
1010
pplx::task<web::http::http_response> HttpClientHelper::Post(
1111
const utility::string_t& uri, const web::json::value& body, const std::unordered_map<utility::string_t, utility::string_t>& headers) const
1212
{
13-
AICLI_LOG(Repo, Verbose, << "Sending http POST request to: " << utility::conversions::to_utf8string(uri));
13+
AICLI_LOG(Repo, Info, << "Sending http POST request to: " << utility::conversions::to_utf8string(uri));
1414
web::http::client::http_client client = GetClient(uri);
1515
web::http::http_request request{ web::http::methods::POST };
1616
request.headers().set_content_type(web::http::details::mime_types::application_json);
@@ -22,6 +22,8 @@ namespace AppInstaller::Repository::Rest::Schema
2222
request.headers().add(pair.first, pair.second);
2323
}
2424

25+
AICLI_LOG(Repo, Verbose, << "Http POST request details:\n" << utility::conversions::to_utf8string(request.to_string()));
26+
2527
return client.request(request);
2628
}
2729

@@ -31,17 +33,16 @@ namespace AppInstaller::Repository::Rest::Schema
3133
web::http::http_response httpResponse;
3234
HttpClientHelper::Post(uri, body, headers).then([&httpResponse](const web::http::http_response& response)
3335
{
34-
AICLI_LOG(Repo, Verbose, << "Response status: " << response.status_code());
3536
httpResponse = response;
3637
}).wait();
3738

38-
return ValidateAndExtractResponse(httpResponse);
39+
return ValidateAndExtractResponse(httpResponse);
3940
}
4041

4142
pplx::task<web::http::http_response> HttpClientHelper::Get(
4243
const utility::string_t& uri, const std::unordered_map<utility::string_t, utility::string_t>& headers) const
4344
{
44-
AICLI_LOG(Repo, Verbose, << "Sending http GET request to: " << utility::conversions::to_utf8string(uri));
45+
AICLI_LOG(Repo, Info, << "Sending http GET request to: " << utility::conversions::to_utf8string(uri));
4546
web::http::client::http_client client = GetClient(uri);
4647
web::http::http_request request{ web::http::methods::GET };
4748
request.headers().set_content_type(web::http::details::mime_types::application_json);
@@ -52,6 +53,8 @@ namespace AppInstaller::Repository::Rest::Schema
5253
request.headers().add(pair.first, pair.second);
5354
}
5455

56+
AICLI_LOG(Repo, Verbose, << "Http GET request details:\n" << utility::conversions::to_utf8string(request.to_string()));
57+
5558
return client.request(request);
5659
}
5760

@@ -61,11 +64,10 @@ namespace AppInstaller::Repository::Rest::Schema
6164
web::http::http_response httpResponse;
6265
Get(uri, headers).then([&httpResponse](const web::http::http_response& response)
6366
{
64-
AICLI_LOG(Repo, Verbose, << "Response status: " << response.status_code());
6567
httpResponse = response;
6668
}).wait();
6769

68-
return ValidateAndExtractResponse(httpResponse);
70+
return ValidateAndExtractResponse(httpResponse);
6971
}
7072

7173
web::http::client::http_client HttpClientHelper::GetClient(const utility::string_t& uri) const
@@ -83,6 +85,9 @@ namespace AppInstaller::Repository::Rest::Schema
8385

8486
std::optional<web::json::value> HttpClientHelper::ValidateAndExtractResponse(const web::http::http_response& response) const
8587
{
88+
AICLI_LOG(Repo, Info, << "Response status: " << response.status_code());
89+
AICLI_LOG(Repo, Verbose, << "Response details: " << utility::conversions::to_utf8string(response.to_string()));
90+
8691
std::optional<web::json::value> result;
8792
switch (response.status_code())
8893
{

0 commit comments

Comments
 (0)