added logging
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/pr-master This commit looks good

This commit is contained in:
2025-07-22 16:58:05 -05:00
parent 8b868f1e1a
commit fdad10c592
8 changed files with 30 additions and 32 deletions

View File

@@ -224,7 +224,7 @@ public:
if (curl_code != CURLE_OK) {
event_system::instance().raise<curl_error>(curl_code, function_name,
url);
request.get_type(), url);
return false;
}

View File

@@ -26,11 +26,13 @@
namespace repertory::curl::requests {
struct http_delete final : http_request_base {
~http_delete() override = default;
[[nodiscard]] auto get_type() const -> std::string override {
return "delete";
}
[[nodiscard]] auto
set_method(CURL *curl,
stop_type & /* stop_requested */) const -> bool override {
[[nodiscard]] auto set_method(CURL *curl,
stop_type & /* stop_requested */) const
-> bool override {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
return true;
}

View File

@@ -33,9 +33,11 @@ struct http_get final : http_request_base {
auto operator=(http_get &&) -> http_get & = default;
~http_get() override = default;
[[nodiscard]] auto
set_method(CURL *curl,
stop_type & /*stop_requested*/) const -> bool override {
[[nodiscard]] auto get_type() const -> std::string override { return "get"; }
[[nodiscard]] auto set_method(CURL *curl,
stop_type & /*stop_requested*/) const
-> bool override {
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
return true;
}

View File

@@ -26,11 +26,11 @@
namespace repertory::curl::requests {
struct http_head final : http_request_base {
~http_head() override = default;
[[nodiscard]] auto get_type() const -> std::string override { return "head"; }
[[nodiscard]] auto
set_method(CURL *curl,
stop_type & /* stop_requested */) const -> bool override {
[[nodiscard]] auto set_method(CURL *curl,
stop_type & /* stop_requested */) const
-> bool override {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "HEAD");
curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
return true;

View File

@@ -26,16 +26,10 @@
namespace repertory::curl::requests {
struct http_post final : http_request_base {
http_post() = default;
http_post(const http_post &) = default;
http_post(http_post &&) = default;
auto operator=(const http_post &) -> http_post & = default;
auto operator=(http_post &&) -> http_post & = default;
~http_post() override = default;
std::optional<nlohmann::json> json;
[[nodiscard]] auto get_type() const -> std::string override { return "post"; }
[[nodiscard]] auto set_method(CURL *curl,
stop_type & /*stop_requested*/) const
-> bool override;

View File

@@ -27,18 +27,11 @@
namespace repertory::curl::requests {
struct http_put_file final : http_request_base {
http_put_file() = default;
http_put_file(const http_put_file &) = default;
http_put_file(http_put_file &&) = default;
auto operator=(const http_put_file &) -> http_put_file & = default;
auto operator=(http_put_file &&) -> http_put_file & = default;
~http_put_file() override = default;
std::shared_ptr<utils::encryption::encrypting_reader> reader;
std::string source_path;
[[nodiscard]] auto get_type() const -> std::string override { return "put"; }
[[nodiscard]] auto set_method(CURL *curl, stop_type &stop_requested) const
-> bool override;

View File

@@ -61,6 +61,8 @@ struct http_request_base {
[[nodiscard]] virtual auto get_path() const -> std::string { return path; }
[[nodiscard]] virtual auto get_type() const -> std::string = 0;
[[nodiscard]] virtual auto set_method(CURL *curl,
stop_type &stop_requested) const
-> bool = 0;

View File

@@ -28,9 +28,11 @@
namespace repertory {
struct curl_error final : public i_event {
curl_error() = default;
curl_error(CURLcode code_, std::string_view function_name_, std::string url_)
curl_error(CURLcode code_, std::string_view function_name_, std::string type_,
std::string url_)
: code(code_),
function_name(std::string{function_name_}),
type(std::move(type_)),
url(std::move(url_)) {}
static constexpr event_level level{event_level::error};
@@ -38,6 +40,7 @@ struct curl_error final : public i_event {
CURLcode code{};
std::string function_name;
std::string type;
std::string url;
[[nodiscard]] auto get_event_level() const -> event_level override {
@@ -49,8 +52,8 @@ struct curl_error final : public i_event {
}
[[nodiscard]] auto get_single_line() const -> std::string override {
return fmt::format("{}|func|{}|url|{}|code|{}", name, function_name, url,
static_cast<int>(code));
return fmt::format("{}|func|{}|type|{}|url|{}|code|{}", name, function_name,
type, url, static_cast<int>(code));
}
};
} // namespace repertory
@@ -60,12 +63,14 @@ template <> struct adl_serializer<repertory::curl_error> {
static void to_json(json &data, const repertory::curl_error &value) {
data["code"] = value.code;
data["function_name"] = value.function_name;
data["type"] = value.type;
data["url"] = value.url;
}
static void from_json(const json &data, repertory::curl_error &value) {
data.at("code").get_to<CURLcode>(value.code);
data.at("function_name").get_to<std::string>(value.function_name);
data.at("type").get_to<std::string>(value.type);
data.at("url").get_to<std::string>(value.url);
}
};