diff options
| author | Stefan Boberg <[email protected]> | 2021-09-07 11:04:47 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-07 11:04:47 +0200 |
| commit | e9b5405146d2a25e50d970e6f33a8adb597b01ce (patch) | |
| tree | 121cad36b51ec71884fb2bc9b571b95864e0bc0d /zenserver/upstream/jupiter.cpp | |
| parent | Further xmake file cleanup (diff) | |
| parent | Merge branch 'main' of https://github.com/EpicGames/zen (diff) | |
| download | zen-e9b5405146d2a25e50d970e6f33a8adb597b01ce.tar.xz zen-e9b5405146d2a25e50d970e6f33a8adb597b01ce.zip | |
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zenserver/upstream/jupiter.cpp')
| -rw-r--r-- | zenserver/upstream/jupiter.cpp | 50 |
1 files changed, 7 insertions, 43 deletions
diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp index d204e8f0b..9a013963a 100644 --- a/zenserver/upstream/jupiter.cpp +++ b/zenserver/upstream/jupiter.cpp @@ -3,6 +3,7 @@ #include "jupiter.h" #include "cache/structuredcachestore.h" +#include "diag/formatters.h" #include "diag/logging.h" #include <fmt/format.h> @@ -52,43 +53,6 @@ namespace detail { cpr::Session Session; }; - static void Log(spdlog::logger& Log, std::string_view Verb, const cpr::Response& Response) - { - std::string_view ContentType = "unknown"sv; - if (auto It = Response.header.find("Content-Type"); It != Response.header.end()) - { - ContentType = It->second; - } - - const uint64_t Bytes = Verb == "GET"sv ? Response.downloaded_bytes : Response.uploaded_bytes; - - const bool IsBinary = - ContentType == "application/x-ue-cb"sv || ContentType == "application/x-ue-comp"sv || ContentType == "application/octet-stream"; - - if (IsBinary) - { - Log.debug("{} '{}', Status: '{}', Elapsed: '{}', Content-Type: '{}' '{}' Bytes, Reason: '{}'", - Verb, - Response.url.str(), - Response.status_code, - Response.elapsed, - ContentType, - Bytes, - Response.reason); - } - else - { - Log.debug("{} '{}', Status: '{}', Elapsed: '{}', Content-Type: '{}': '{}', Reason: '{}'", - Verb, - Response.url.str(), - Response.status_code, - Response.elapsed, - ContentType, - Response.text, - Response.reason); - } - } - } // namespace detail CloudCacheSession::CloudCacheSession(CloudCacheClient* OuterClient) : m_Log(OuterClient->Logger()), m_CacheClient(OuterClient) @@ -117,7 +81,7 @@ CloudCacheSession::GetDerivedData(std::string_view BucketId, std::string_view Ke cpr::Response Response = Session.Get(); - detail::Log(m_Log, "GET"sv, Response); + m_Log.debug("GET {}", Response); if (Response.status_code == 200) { @@ -150,7 +114,7 @@ CloudCacheSession::GetRef(std::string_view BucketId, const IoHash& Key, ZenConte Session.SetOption(cpr::Header{{"Authorization", Auth}, {"Accept", ContentType}}); cpr::Response Response = Session.Get(); - detail::Log(m_Log, "GET"sv, Response); + m_Log.debug("GET {}", Response); if (Response.status_code == 200) { @@ -175,7 +139,7 @@ CloudCacheSession::GetCompressedBlob(const IoHash& Key) Session.SetOption(cpr::Header{{"Authorization", Auth}, {"Accept", "application/x-ue-comp"}}); cpr::Response Response = Session.Get(); - detail::Log(m_Log, "GET"sv, Response); + m_Log.debug("GET {}", Response); if (Response.status_code == 200) { @@ -204,7 +168,7 @@ CloudCacheSession::PutDerivedData(std::string_view BucketId, std::string_view Ke Session.SetBody(cpr::Body{(const char*)DerivedData.Data(), DerivedData.Size()}); cpr::Response Response = Session.Put(); - detail::Log(m_Log, "PUT"sv, Response); + m_Log.debug("PUT {}", Response); return {.Success = Response.status_code == 200}; } @@ -235,7 +199,7 @@ CloudCacheSession::PutRef(std::string_view BucketId, const IoHash& Key, IoBuffer Session.SetBody(cpr::Body{(const char*)Ref.Data(), Ref.Size()}); cpr::Response Response = Session.Put(); - detail::Log(m_Log, "PUT"sv, Response); + m_Log.debug("PUT {}", Response); return {.Success = Response.status_code == 200}; } @@ -256,7 +220,7 @@ CloudCacheSession::PutCompressedBlob(const IoHash& Key, IoBuffer Blob) Session.SetBody(cpr::Body{(const char*)Blob.Data(), Blob.Size()}); cpr::Response Response = Session.Put(); - detail::Log(m_Log, "PUT"sv, Response); + m_Log.debug("PUT {}", Response); return {.Success = Response.status_code == 200}; } |