aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-05-23 15:00:55 +0200
committerGitHub <[email protected]>2023-05-23 15:00:55 +0200
commit55844c3f72866711f9a10b987f14da5622cc2d63 (patch)
treea872fdb170bf1019cdb4b5cc17c53dcc1585e3cc /src/zenutil/include
parentuse exception when allocations fail rather than asserts (#319) (diff)
downloadzen-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.h28
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);
+ }
+};