]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
feat: Log URLs requested by http backend
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 9 Jun 2025 15:06:44 +0000 (17:06 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 9 Jun 2025 15:06:44 +0000 (17:06 +0200)
src/ccache/storage/remote/httpstorage.cpp

index a1ae2cc5dcb4a1470d1b8c99a94786c2c963abbc..8ed1cb967ef2c5ee437c4fc6875a3bfa3bc1edc9 100644 (file)
@@ -56,6 +56,7 @@ public:
 private:
   enum class Layout : uint8_t { bazel, flat, subdirs };
 
+  Url m_url;
   std::string m_url_path;
   httplib::Client m_http_client;
   Layout m_layout = Layout::subdirs;
@@ -107,7 +108,8 @@ failure_from_httplib_error(httplib::Error error)
 
 HttpStorageBackend::HttpStorageBackend(
   const Url& url, const std::vector<Backend::Attribute>& attributes)
-  : m_url_path(get_url_path(url)),
+  : m_url(url),
+    m_url_path(get_url_path(url)),
     m_http_client(get_url(url))
 {
   if (!url.user_info().empty()) {
@@ -170,6 +172,7 @@ HttpStorageBackend::get(const Hash::Digest& key)
 {
   const auto url_path = get_entry_path(key);
   const auto result = m_http_client.Get(url_path);
+  LOG("GET {}{} -> {}", m_url.str(), url_path, result->status);
 
   if (result.error() != httplib::Error::Success || !result) {
     LOG("Failed to get {} from http storage: {} ({})",
@@ -196,6 +199,7 @@ HttpStorageBackend::put(const Hash::Digest& key,
 
   if (only_if_missing) {
     const auto result = m_http_client.Head(url_path);
+    LOG("HEAD {}{} -> {}", m_url.str(), url_path, result->status);
 
     if (result.error() != httplib::Error::Success || !result) {
       LOG("Failed to check for {} in http storage: {} ({})",
@@ -219,6 +223,7 @@ HttpStorageBackend::put(const Hash::Digest& key,
                       reinterpret_cast<const char*>(value.data()),
                       value.size(),
                       content_type);
+  LOG("PUT {}{} -> {}", m_url.str(), url_path, result->status);
 
   if (result.error() != httplib::Error::Success || !result) {
     LOG("Failed to put {} to http storage: {} ({})",
@@ -243,6 +248,7 @@ HttpStorageBackend::remove(const Hash::Digest& key)
 {
   const auto url_path = get_entry_path(key);
   const auto result = m_http_client.Delete(url_path);
+  LOG("DELETE {}{} -> {}", m_url.str(), url_path, result->status);
 
   if (result.error() != httplib::Error::Success || !result) {
     LOG("Failed to delete {} from http storage: {} ({})",