20 Mutex Console::mutex(
"console");
21 bool Console::newline =
false;
22 vector<string> Console::messages;
23 Console::Logger* Console::logger =
nullptr;
24 unique_ptr<Console::LogWriterThread> Console::logWriterThread = make_unique<Console::LogWriterThread>();
26 Console::LogWriterThread::LogWriterThread():
Thread(
"console-logwriter-thread") {
27 ofstream ofs(std::filesystem::u8path(
"console.log"), ofstream::trunc);
36 while (isStopRequested() ==
false) {
48 ofstream ofs(std::filesystem::u8path(
"console.log"), ofstream::app);
50 ofs << message << endl;
void unlock()
Unlocks this mutex.
void lock()
Locks the mutex, additionally mutex locks will block until other locks have been unlocked.
virtual void start()
Starts this objects thread.
void run()
Abstract run() method, should be implemented by subclassed class, will be called after spawn by start...
static void println()
Print new line to console.
static void setLogger(Logger *logger)
Set logger.
static STATIC_DLL_IMPEXT bool newline
static void shutdown()
Shutdown console logging and especially writing log to file.
static STATIC_DLL_IMPEXT vector< string > messages
static STATIC_DLL_IMPEXT Logger * logger
static void print(const string_view &str)
Print given string.
static STATIC_DLL_IMPEXT unique_ptr< LogWriterThread > logWriterThread
static constexpr int HISTORY_LINECOUNT
static STATIC_DLL_IMPEXT Mutex mutex
virtual void println(const string_view &str)=0
virtual void print(const string_view &str)=0