diff options
| author | Stefan Boberg <[email protected]> | 2026-03-15 12:53:46 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2026-03-15 12:53:46 +0100 |
| commit | 0da02a3e6d13c1626e6422f6d7ead3848036a146 (patch) | |
| tree | 94a6cd36c25df00455a727850fb14d440dc5b0c5 /src/zenutil/include | |
| parent | Use gathered buffer sequence in TcpLogStreamSink for batched TCP writes (diff) | |
| download | zen-sb/sessionize.tar.xz zen-sb/sessionize.zip | |
Add sequence numbers to log stream protocol and tests for drop detectionsb/sessionize
TcpLogStreamSink now stamps each message with a monotonic sequence number.
LogStreamListener tracks the expected sequence per session and emits a
synthetic "dropped" notice when gaps appear. Includes tests covering
basic delivery, multi-line splitting, drop detection, and contiguous
sequencing. Also simplifies LogMessage::s_DefaultPoint to a single entry.
Diffstat (limited to 'src/zenutil/include')
| -rw-r--r-- | src/zenutil/include/zenutil/splitconsole/logstreamlistener.h | 2 | ||||
| -rw-r--r-- | src/zenutil/include/zenutil/splitconsole/tcplogstreamsink.h | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/zenutil/include/zenutil/splitconsole/logstreamlistener.h b/src/zenutil/include/zenutil/splitconsole/logstreamlistener.h index a0e39ba47..f3b960f51 100644 --- a/src/zenutil/include/zenutil/splitconsole/logstreamlistener.h +++ b/src/zenutil/include/zenutil/splitconsole/logstreamlistener.h @@ -56,4 +56,6 @@ private: std::unique_ptr<Impl> m_Impl; }; +void logstreamlistener_forcelink(); + } // namespace zen diff --git a/src/zenutil/include/zenutil/splitconsole/tcplogstreamsink.h b/src/zenutil/include/zenutil/splitconsole/tcplogstreamsink.h index e6320d9d5..f4ac5ff22 100644 --- a/src/zenutil/include/zenutil/splitconsole/tcplogstreamsink.h +++ b/src/zenutil/include/zenutil/splitconsole/tcplogstreamsink.h @@ -11,6 +11,7 @@ ZEN_THIRD_PARTY_INCLUDES_START #include <asio.hpp> ZEN_THIRD_PARTY_INCLUDES_END +#include <atomic> #include <condition_variable> #include <deque> #include <mutex> @@ -60,11 +61,14 @@ public: Text.remove_suffix(1); } - // Build CbObject with text, source, and level fields + uint64_t Seq = m_NextSequence.fetch_add(1, std::memory_order_relaxed); + + // Build CbObject with text, source, level, and sequence number fields CbObjectWriter Writer; Writer.AddString("text", Text); Writer.AddString("source", m_Source); Writer.AddString("level", logging::ToStringView(Msg.GetLevel())); + Writer.AddInteger("seq", Seq); CbObject Obj = Writer.Save(); // Enqueue for async write @@ -172,6 +176,10 @@ private: std::string m_Source; uint32_t m_MaxQueueSize; + // Sequence counter — incremented atomically by Log() callers. + // Gaps in the sequence seen by the receiver indicate dropped messages. + std::atomic<uint64_t> m_NextSequence{0}; + // Queue shared between Log() callers and IO thread std::mutex m_QueueMutex; std::condition_variable m_QueueCv; |