vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
engine_error_log.h
1#pragma once
2
3#include <chrono>
4#include <cstddef>
5#include <string>
6#include <vector>
7
8namespace Vkm::Engine {
9
15class EngineErrorLog {
16 public:
17 struct Entry {
18 std::chrono::system_clock::time_point timestamp;
19 std::string category;
20 std::string source;
21 std::string message;
22 unsigned int repeatCount = 1;
23 };
24
25 static constexpr std::size_t CAPACITY = 64;
26
27 public:
28 EngineErrorLog() = default;
29 ~EngineErrorLog() = default;
30
31 EngineErrorLog(const EngineErrorLog& other) = delete;
32 EngineErrorLog& operator=(const EngineErrorLog& other) = delete;
33
34 EngineErrorLog(EngineErrorLog && other) = delete;
35 EngineErrorLog& operator=(EngineErrorLog && other) = delete;
36
37 public:
47 void push(std::string category, std::string source, std::string message);
48
52 void clearAll();
53
59 const std::vector<Entry>& entries() const { return m_entries; }
60
68 unsigned long long totalPushed() const { return m_totalPushed; }
69
70 private:
71 std::vector<Entry> m_entries;
72 unsigned long long m_totalPushed = 0;
73};
74
84void reportError(const char* category, std::string source, std::string message);
85
91void setErrorSink(EngineErrorLog* sink);
92
93} // namespace Vkm::Engine
void push(std::string category, std::string source, std::string message)
Record an error, dropping the oldest entries past CAPACITY.
void clearAll()
Drop every buffered entry.
const std::vector< Entry > & entries() const
The buffered entries.
Definition engine_error_log.h:59
unsigned long long totalPushed() const
Monotonic count of entries ever appended.
Definition engine_error_log.h:68