mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 11:23:42 +00:00
add logs to http_get/post/put/delete
This commit is contained in:
@@ -1784,7 +1784,8 @@ int OrcaCloudServiceAgent::http_get(const std::string& path, std::string* respon
|
|||||||
std::string url = api_base_url + path;
|
std::string url = api_base_url + path;
|
||||||
BOOST_LOG_TRIVIAL(trace) << "OrcaCloudServiceAgent: GET " << url;
|
BOOST_LOG_TRIVIAL(trace) << "OrcaCloudServiceAgent: GET " << url;
|
||||||
|
|
||||||
ensure_token_fresh("http_get_" + path);
|
if (!ensure_token_fresh("http_get_" + path))
|
||||||
|
BOOST_LOG_TRIVIAL(warning) << "ensure_token_fresh returned false";
|
||||||
|
|
||||||
struct HttpResult {
|
struct HttpResult {
|
||||||
bool success{false};
|
bool success{false};
|
||||||
@@ -1816,8 +1817,9 @@ int OrcaCloudServiceAgent::http_get(const std::string& path, std::string* respon
|
|||||||
})
|
})
|
||||||
.on_error([&](std::string body, std::string error, unsigned resp_status) {
|
.on_error([&](std::string body, std::string error, unsigned resp_status) {
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.status = resp_status;
|
result.status = resp_status == 0 ? 404 : resp_status;
|
||||||
result.body = body;
|
result.body = body;
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error;
|
||||||
})
|
})
|
||||||
.timeout_max(30)
|
.timeout_max(30)
|
||||||
.perform_sync();
|
.perform_sync();
|
||||||
@@ -1885,8 +1887,9 @@ int OrcaCloudServiceAgent::http_post(const std::string& path, const std::string&
|
|||||||
})
|
})
|
||||||
.on_error([&](std::string resp_body, std::string error, unsigned resp_status) {
|
.on_error([&](std::string resp_body, std::string error, unsigned resp_status) {
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.status = resp_status;
|
result.status = resp_status == 0 ? 404 : resp_status;
|
||||||
result.body = resp_body;
|
result.body = body;
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error;
|
||||||
})
|
})
|
||||||
.timeout_max(30)
|
.timeout_max(30)
|
||||||
.perform_sync();
|
.perform_sync();
|
||||||
@@ -1954,8 +1957,9 @@ int OrcaCloudServiceAgent::http_put(const std::string& path, const std::string&
|
|||||||
})
|
})
|
||||||
.on_error([&](std::string resp_body, std::string error, unsigned resp_status) {
|
.on_error([&](std::string resp_body, std::string error, unsigned resp_status) {
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.status = resp_status;
|
result.status = resp_status == 0 ? 404 : resp_status;
|
||||||
result.body = resp_body;
|
result.body = body;
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error;
|
||||||
})
|
})
|
||||||
.timeout_max(30)
|
.timeout_max(30)
|
||||||
.perform_sync();
|
.perform_sync();
|
||||||
@@ -2020,8 +2024,9 @@ int OrcaCloudServiceAgent::http_delete(const std::string& path, std::string* res
|
|||||||
})
|
})
|
||||||
.on_error([&](std::string resp_body, std::string error, unsigned resp_status) {
|
.on_error([&](std::string resp_body, std::string error, unsigned resp_status) {
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.status = resp_status;
|
result.status = resp_status == 0 ? 404 : resp_status;
|
||||||
result.body = resp_body;
|
result.body = resp_body;
|
||||||
|
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error;
|
||||||
})
|
})
|
||||||
.timeout_max(30)
|
.timeout_max(30)
|
||||||
.perform_sync();
|
.perform_sync();
|
||||||
@@ -2102,7 +2107,7 @@ bool OrcaCloudServiceAgent::http_post_token(const std::string& body, std::string
|
|||||||
})
|
})
|
||||||
.on_error([&](std::string body, std::string error, unsigned resp_status) {
|
.on_error([&](std::string body, std::string error, unsigned resp_status) {
|
||||||
success = false;
|
success = false;
|
||||||
status = resp_status;
|
status = resp_status == 0 ? 404 : resp_status;
|
||||||
resp_body = body;
|
resp_body = body;
|
||||||
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error;
|
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP error - " << error;
|
||||||
})
|
})
|
||||||
@@ -2172,7 +2177,7 @@ bool OrcaCloudServiceAgent::http_post_auth(const std::string& path, const std::s
|
|||||||
})
|
})
|
||||||
.on_error([&](std::string body, std::string error, unsigned resp_status) {
|
.on_error([&](std::string body, std::string error, unsigned resp_status) {
|
||||||
success = false;
|
success = false;
|
||||||
status = resp_status;
|
status = resp_status == 0 ? 404 : resp_status;
|
||||||
resp_body = body;
|
resp_body = body;
|
||||||
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP (auth) error - " << error;
|
BOOST_LOG_TRIVIAL(error) << "OrcaCloudServiceAgent: HTTP (auth) error - " << error;
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user