AuroraRuntime/Source/Logging/Sinks/RingBuffer.hpp
Jamie Reece Wilson ca2c0462ab [*] Continue to refactor allocations of synchronization primitive away
[*] NT: Fix missing CoTaskMemFree leak on startup
[*] Fix ConsoleStd restart bug
2023-06-28 10:33:12 +01:00

35 lines
1.0 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: RingBuffer.hpp
Date: 2022-1-24
Author: Reece
***/
#pragma once
namespace Aurora::Logging::Sinks
{
struct RingBufferSink : IBasicSinkRB
{
RingBufferSink(AuUInt32 count);
bool Init();
void OnMessageBlocking(AuUInt8 level, const ConsoleMessage &msg) override;
bool OnMessageNonblocking(AuUInt8 level, const ConsoleMessage &msg) override;
void OnFlush() override;
void SaveToPath(const AuString &path, bool binary = false) override;
AuList<ConsoleMessage> Export() override;
bool TryAddMsg(AuUInt8 level, const ConsoleMessage &msg, bool &drop);
private:
AuUInt32 maxCount_;
AuUInt32 index_;
AuList<ConsoleMessage> logBuffer_;
AuThreadPrimitives::Mutex logMutex_;
};
void NewRingBufferRelease(IBasicSink *logger);
IBasicSinkRB *NewRingBufferNew(AuUInt32 maxLogEntries);
}