From 9092f9268c444b96a535a41cde95bff570530907 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Tue, 24 Oct 2023 18:37:34 +0100 Subject: [PATCH] [+] void IBasicSinkRB::PreviewRingBuffer --- Include/Aurora/Logging/IBasicSinkRB.hpp | 2 ++ Source/Logging/Sinks/RingBuffer.cpp | 11 +++++++++++ Source/Logging/Sinks/RingBuffer.hpp | 2 ++ 3 files changed, 15 insertions(+) diff --git a/Include/Aurora/Logging/IBasicSinkRB.hpp b/Include/Aurora/Logging/IBasicSinkRB.hpp index 6b01858a..7c754faa 100644 --- a/Include/Aurora/Logging/IBasicSinkRB.hpp +++ b/Include/Aurora/Logging/IBasicSinkRB.hpp @@ -21,5 +21,7 @@ namespace Aurora::Logging * This method does not clear the ring buffer */ virtual AuList Export() = 0; + + virtual void PreviewRingBuffer(AuConsumer&, AuUInt32>> callback) = 0; }; } \ No newline at end of file diff --git a/Source/Logging/Sinks/RingBuffer.cpp b/Source/Logging/Sinks/RingBuffer.cpp index f3006343..2ad46c68 100644 --- a/Source/Logging/Sinks/RingBuffer.cpp +++ b/Source/Logging/Sinks/RingBuffer.cpp @@ -113,6 +113,17 @@ namespace Aurora::Logging::Sinks return messages; } + void RingBufferSink::PreviewRingBuffer(AuConsumer &, AuUInt32>> callback) + { + if (!callback) + { + return; + } + + AU_LOCK_GUARD(this->logMutex_); + callback(AuMakePair(AuConstReference(this->logBuffer_), this->index_)); + } + void RingBufferSink::OnFlush() { } diff --git a/Source/Logging/Sinks/RingBuffer.hpp b/Source/Logging/Sinks/RingBuffer.hpp index fdce8225..e400acfa 100644 --- a/Source/Logging/Sinks/RingBuffer.hpp +++ b/Source/Logging/Sinks/RingBuffer.hpp @@ -22,6 +22,8 @@ namespace Aurora::Logging::Sinks void SaveToPath(const AuString &path, bool binary = false) override; AuList Export() override; + void PreviewRingBuffer(AuConsumer &, AuUInt32>> callback) override; + bool TryAddMsg(AuUInt8 level, const ConsoleMessage &msg, bool &drop); private: AuUInt32 maxCount_;