From f2aab0df9fc96162e603eaa50922369de81a0447 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 8 Sep 2023 09:47:35 -0400 Subject: add console logging to zen command (#389) properly set trace log level if IsVerbose add log category to http client --- src/zenhttp/httpclient.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/zenhttp/httpclient.cpp') diff --git a/src/zenhttp/httpclient.cpp b/src/zenhttp/httpclient.cpp index f3a9ad71b..b77b31933 100644 --- a/src/zenhttp/httpclient.cpp +++ b/src/zenhttp/httpclient.cpp @@ -121,7 +121,7 @@ CommonResponse(cpr::Response&& HttpResponse, IoBuffer&& Payload = {}) struct HttpClient::Impl : public RefCounted { - Impl(); + Impl(spdlog::logger& Log); ~Impl(); // Session allocation @@ -169,6 +169,8 @@ struct HttpClient::Impl : public RefCounted return Result; } + spdlog::logger& Logger() { return Outer->Logger(); } + private: Impl* Outer; cpr::Session* CprSession; @@ -183,14 +185,17 @@ struct HttpClient::Impl : public RefCounted const KeyValueMap& AdditionalHeader, const KeyValueMap& Parameters); + spdlog::logger& Logger() { return m_Log; } + private: + spdlog::logger& m_Log; RwLock m_SessionLock; std::vector m_Sessions; void ReleaseSession(cpr::Session*); }; -HttpClient::Impl::Impl() +HttpClient::Impl::Impl(spdlog::logger& Log) : m_Log(Log) { } @@ -420,9 +425,10 @@ private: ////////////////////////////////////////////////////////////////////////// HttpClient::HttpClient(std::string_view BaseUri, const HttpClientSettings& Connectionsettings) -: m_BaseUri(BaseUri) +: m_Log(zen::logging::Get(Connectionsettings.LogCategory)) +, m_BaseUri(BaseUri) , m_ConnectionSettings(Connectionsettings) -, m_Impl(new Impl) +, m_Impl(new Impl(m_Log)) { StringBuilder<32> SessionId; GetSessionId().ToString(SessionId); -- cgit v1.2.3