diff options
| author | Stefan Boberg <[email protected]> | 2023-05-23 15:00:55 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-23 15:00:55 +0200 |
| commit | 55844c3f72866711f9a10b987f14da5622cc2d63 (patch) | |
| tree | a872fdb170bf1019cdb4b5cc17c53dcc1585e3cc /src/zenutil/include | |
| parent | use exception when allocations fail rather than asserts (#319) (diff) | |
| download | zen-55844c3f72866711f9a10b987f14da5622cc2d63.tar.xz zen-55844c3f72866711f9a10b987f14da5622cc2d63.zip | |
cache log sessionid (#297)
* implemented structured cache logging to be used as audit trail to help analyse potential cache pollution/corruption
* added common header to all known log targets
* made Oid::operator bool explicit to avoid logging/text format mishaps
* HttpClient::operator bool -> explicit
* changed cache logs to not rotate on start in order to retain more history
* added CacheRequestContext
* properly initialize request context
* log session id and request id on zencacehstore get/put
* changelog
Diffstat (limited to 'src/zenutil/include')
| -rw-r--r-- | src/zenutil/include/zenutil/cache/cache.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/zenutil/include/zenutil/cache/cache.h b/src/zenutil/include/zenutil/cache/cache.h index 1a1dd9386..5e12c488c 100644 --- a/src/zenutil/include/zenutil/cache/cache.h +++ b/src/zenutil/include/zenutil/cache/cache.h @@ -4,3 +4,31 @@ #include <zenutil/cache/cachekey.h> #include <zenutil/cache/cachepolicy.h> + +ZEN_THIRD_PARTY_INCLUDES_START +#include <fmt/format.h> +ZEN_THIRD_PARTY_INCLUDES_END + +namespace zen { + +struct CacheRequestContext +{ + Oid SessionId{Oid::Zero}; + uint32_t RequestId{0}; +}; + +} // namespace zen + +template<> +struct fmt::formatter<zen::CacheRequestContext> : formatter<string_view> +{ + template<typename FormatContext> + auto format(const zen::CacheRequestContext& Context, FormatContext& ctx) + { + zen::ExtendableStringBuilder<64> String; + Context.SessionId.ToString(String); + String << "."; + String << Context.RequestId; + return formatter<string_view>::format(String.ToView(), ctx); + } +}; |