-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogManager.h
More file actions
38 lines (32 loc) · 1.53 KB
/
LogManager.h
File metadata and controls
38 lines (32 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <stdint.h>
#include <gtkmm.h>
class LogManager{
private:
// the log gets stored in a ring buffer
// currently, no locking is done as nothing is threaded yet. It will likely be needed later though
char* buffer; // the buffer the log gets stored in
uint32_t max; // the maximum offset in the buffer
uint32_t start; // the offset at which the earliest full log message starts in the buffer
uint32_t wptr; // wptr and rptr for the ring buffer
uint32_t rptr;
int consoleOutput; // from which log level upwards the log messages should also get printed to the console
Gtk::TextBuffer* textBuffer;
Gtk::TextView* view; // needed to enable auto scrolling
// the text tags to format the different log levels
// this might be better placed in LogViewer, but that mostly just contains the widgets, while the LogManager does everything else
Glib::RefPtr<Gtk::TextTag> debugTag;
Glib::RefPtr<Gtk::TextTag> infoTag;
Glib::RefPtr<Gtk::TextTag> warningTag;
Glib::RefPtr<Gtk::TextTag> errorTag;
Glib::RefPtr<Gtk::TextTag> criticalTag;
void createTags();
Glib::RefPtr<Gtk::TextTag> getTag(int level);
public:
LogManager(uint32_t size, int consoleOutputLevel, Gtk::TextBuffer* textBuffer); // the size of the buffer
~LogManager();
void submitLog(const char* buf, uint32_t len); // expects a null-terminated string
void updateBuffer(); // writes everything that hasn't been read yet from the ring buffer into the text buffer and updates the rptr
void setTextBuffer(Gtk::TextBuffer* textBuffer);
void setTextView(Gtk::TextView* view);
};