diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-10-31 16:33:19 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-11-14 13:35:01 +0100 |
commit | e4aee9470da57a47d029f15ffa6795fba0398d60 (patch) | |
tree | d56010a51da48e5f55945d86d99780831ae5fe1c /src/other_tools/utils/curl_easy_handle.hpp | |
parent | fca9ce75d5cb6d90edab84aec5fdfea7af7d8b59 (diff) | |
download | justbuild-e4aee9470da57a47d029f15ffa6795fba0398d60.tar.gz |
curl_easy_handle: Allow non-fatal logging of errors in curl operations
In order to allow non-fatal retries of fetches, be it from same
remote or not (e.g., mirrors), the handle now reports with a
caller-defined LogLevel.
Diffstat (limited to 'src/other_tools/utils/curl_easy_handle.hpp')
-rw-r--r-- | src/other_tools/utils/curl_easy_handle.hpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/other_tools/utils/curl_easy_handle.hpp b/src/other_tools/utils/curl_easy_handle.hpp index 470f6f2a..4c03d968 100644 --- a/src/other_tools/utils/curl_easy_handle.hpp +++ b/src/other_tools/utils/curl_easy_handle.hpp @@ -22,6 +22,7 @@ #include <string> #include "gsl/gsl" +#include "src/buildtool/logging/log_level.hpp" #include "src/other_tools/utils/curl_context.hpp" extern "C" { @@ -46,13 +47,15 @@ class CurlEasyHandle { auto operator=(CurlEasyHandle&& other) = delete; /// \brief Create a CurlEasyHandle object - [[nodiscard]] auto static Create() noexcept + [[nodiscard]] auto static Create( + LogLevel log_level = LogLevel::Error) noexcept -> std::shared_ptr<CurlEasyHandle>; /// \brief Create a CurlEasyHandle object with non-default CA info [[nodiscard]] auto static Create( bool no_ssl_verify, - std::optional<std::filesystem::path> const& ca_bundle) noexcept + std::optional<std::filesystem::path> const& ca_bundle, + LogLevel log_level = LogLevel::Error) noexcept -> std::shared_ptr<CurlEasyHandle>; /// \brief Download file from URL into given file_path. @@ -73,6 +76,8 @@ class CurlEasyHandle { std::unique_ptr<CURL, decltype(&curl_easy_closer)> handle_{ nullptr, curl_easy_closer}; + // allow also non-fatal logging of curl operations + LogLevel log_level_{}; bool no_ssl_verify_{false}; std::optional<std::filesystem::path> ca_bundle_{std::nullopt}; |