From e4aee9470da57a47d029f15ffa6795fba0398d60 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 31 Oct 2023 16:33:19 +0100 Subject: 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. --- src/other_tools/utils/curl_easy_handle.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/other_tools/utils/curl_easy_handle.hpp') 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 #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; /// \brief Create a CurlEasyHandle object with non-default CA info [[nodiscard]] auto static Create( bool no_ssl_verify, - std::optional const& ca_bundle) noexcept + std::optional const& ca_bundle, + LogLevel log_level = LogLevel::Error) noexcept -> std::shared_ptr; /// \brief Download file from URL into given file_path. @@ -73,6 +76,8 @@ class CurlEasyHandle { std::unique_ptr handle_{ nullptr, curl_easy_closer}; + // allow also non-fatal logging of curl operations + LogLevel log_level_{}; bool no_ssl_verify_{false}; std::optional ca_bundle_{std::nullopt}; -- cgit v1.2.3