File LogBuffer.hpp¶
File List > Engine > include > Logging > LogBuffer.hpp
Go to the documentation of this file
#ifndef ENGINE_LOGGING_LOGBUFFER_HPP_
#define ENGINE_LOGGING_LOGBUFFER_HPP_
#include "Logging/LogConfig.hpp"
#include <cstddef>
#include <mutex>
#include <string>
#include <vector>
namespace Engine {
struct LogEntry {
LogLevel level;
std::string message;
};
class LogBuffer {
public:
static constexpr std::size_t Capacity = 512;
LogBuffer();
void Push(LogLevel level, const std::string& message);
void CopyEntriesInOrder(std::vector<LogEntry>& out) const;
private:
std::vector<LogEntry> m_Entries;
mutable std::mutex m_Mutex;
std::size_t m_WriteIndex = 0;
std::size_t m_Count = 0;
};
LogBuffer& GetLogBuffer();
} // namespace Engine
#endif // ENGINE_LOGGING_LOGBUFFER_HPP_