diff options
| author | Stefan Boberg <[email protected]> | 2021-09-15 11:27:48 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-15 11:27:48 +0200 |
| commit | 2b9bed6635d95e15847c4d9b602e34d90e277d14 (patch) | |
| tree | 66fb191150ccbf9f56315a716abd23b25cc1d401 /zenserver/upstream/upstreamcache.cpp | |
| parent | xmake: added zenhttp dependency to make zen CLI tool buld (diff) | |
| download | zen-2b9bed6635d95e15847c4d9b602e34d90e277d14.tar.xz zen-2b9bed6635d95e15847c4d9b602e34d90e277d14.zip | |
Changed logging implementation
* Code should no longer directly `#include spdlog/spdlog.h`, instead use `#include <zencore/logging.h>`
* Instead of explicit calls to `spdlog::info(...)` and such please use the logging macros defined in `zencore/logging.h`. I.e `ZEN_INFO`, `ZEN_DEBUG`, `ZEN_TRACE`, `ZEN_ERROR`, `ZEN_CRITITCAL`
* The macros will pick up the "most local" logger via a `Log()` call to retrieve a logger instance. To override the default logger in a class please implement your own `Log()` function
Diffstat (limited to 'zenserver/upstream/upstreamcache.cpp')
| -rw-r--r-- | zenserver/upstream/upstreamcache.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp index aef9c0bb3..97b222a68 100644 --- a/zenserver/upstream/upstreamcache.cpp +++ b/zenserver/upstream/upstreamcache.cpp @@ -419,17 +419,19 @@ private: ZEN_UNUSED(Endpoint); - m_Log.info("{} Endpoint: {}, Bytes: {:.2f} MB, Time: {:.2f} s, Speed: {:.2f} MB/s, Avg: {:.2f} ms/request, Samples: {}", - What, - Kv.first->DisplayName(), - TotalMb, - Counters.Seconds, - TotalMb / Counters.Seconds, - (Counters.Seconds * 1000.0) / double(Counters.Count), - Counters.Count); + ZEN_INFO("{} Endpoint: {}, Bytes: {:.2f} MB, Time: {:.2f} s, Speed: {:.2f} MB/s, Avg: {:.2f} ms/request, Samples: {}", + What, + Kv.first->DisplayName(), + TotalMb, + Counters.Seconds, + TotalMb / Counters.Seconds, + (Counters.Seconds * 1000.0) / double(Counters.Count), + Counters.Count); } } + spdlog::logger& Log() { return m_Log; } + spdlog::logger& m_Log; EndpointStats m_UpStats; EndpointStats m_DownStats; @@ -455,7 +457,7 @@ public: { auto NewEnd = std::remove_if(std::begin(m_Endpoints), std::end(m_Endpoints), [this](auto& Endpoint) { const bool Ok = Endpoint->Initialize(); - m_Log.info("{} [{}]", Endpoint->DisplayName(), Ok ? "OK" : "FAILED"); + ZEN_INFO("{} [{}]", Endpoint->DisplayName(), Ok ? "OK" : "FAILED"); return !Ok; }); @@ -522,9 +524,9 @@ private: if (!m_CacheStore.Get(CacheRecord.CacheKey.Bucket, CacheRecord.CacheKey.Hash, CacheValue)) { - m_Log.warn("process upstream FAILED, '{}/{}', cache record doesn't exist", - CacheRecord.CacheKey.Bucket, - CacheRecord.CacheKey.Hash); + ZEN_WARN("process upstream FAILED, '{}/{}', cache record doesn't exist", + CacheRecord.CacheKey.Bucket, + CacheRecord.CacheKey.Hash); return; } @@ -536,10 +538,10 @@ private: } else { - m_Log.warn("process upstream FAILED, '{}/{}/{}', payload doesn't exist in CAS", - CacheRecord.CacheKey.Bucket, - CacheRecord.CacheKey.Hash, - PayloadId); + ZEN_WARN("process upstream FAILED, '{}/{}/{}', payload doesn't exist in CAS", + CacheRecord.CacheKey.Bucket, + CacheRecord.CacheKey.Hash, + PayloadId); return; } } @@ -567,7 +569,7 @@ private: } catch (std::exception& e) { - m_Log.warn("process upstream ({}/{}) FAILED '{}'", CacheRecord.CacheKey.Bucket, CacheRecord.CacheKey.Hash, e.what()); + ZEN_WARN("process upstream ({}/{}) FAILED '{}'", CacheRecord.CacheKey.Bucket, CacheRecord.CacheKey.Hash, e.what()); } } @@ -597,6 +599,8 @@ private: using UpstreamQueue = detail::BlockingQueue<UpstreamCacheRecord>; + spdlog::logger& Log() { return m_Log; } + spdlog::logger& m_Log; UpstreamCacheOptions m_Options; ::ZenCacheStore& m_CacheStore; |