[+] void IBasicSinkRB::PreviewRingBuffer

This commit is contained in:
Reece Wilson 2023-10-24 18:37:34 +01:00
parent 1735fa9c6c
commit 9092f9268c
3 changed files with 15 additions and 0 deletions

View File

@ -21,5 +21,7 @@ namespace Aurora::Logging
* This method does not clear the ring buffer
*/
virtual AuList<ConsoleMessage> Export() = 0;
virtual void PreviewRingBuffer(AuConsumer<AuPair<const AuList<ConsoleMessage>&, AuUInt32>> callback) = 0;
};
}

View File

@ -113,6 +113,17 @@ namespace Aurora::Logging::Sinks
return messages;
}
void RingBufferSink::PreviewRingBuffer(AuConsumer<AuPair<const AuList<ConsoleMessage> &, AuUInt32>> callback)
{
if (!callback)
{
return;
}
AU_LOCK_GUARD(this->logMutex_);
callback(AuMakePair(AuConstReference(this->logBuffer_), this->index_));
}
void RingBufferSink::OnFlush()
{
}

View File

@ -22,6 +22,8 @@ namespace Aurora::Logging::Sinks
void SaveToPath(const AuString &path, bool binary = false) override;
AuList<ConsoleMessage> Export() override;
void PreviewRingBuffer(AuConsumer<AuPair<const AuList<ConsoleMessage> &, AuUInt32>> callback) override;
bool TryAddMsg(AuUInt8 level, const ConsoleMessage &msg, bool &drop);
private:
AuUInt32 maxCount_;