diff common/logstream.cpp @ 0:a4671277546c tip

created the repository for the thymian project
author ferencd
date Tue, 17 Aug 2021 11:19:54 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/logstream.cpp	Tue Aug 17 11:19:54 2021 +0200
@@ -0,0 +1,30 @@
+#include "logstream.h"
+#include "logger.h"
+#include <thread>
+
+
+logstream::logstream(int line, const char pFile[], const char pFunc[], unafrog::log::LogLevel level) :
+    mFile(pFile),
+    mFunc(pFunc),
+    mLevel(level),
+    mLine(line)
+{}
+
+logstream::~logstream()
+{
+    std::stringstream arguments;
+    std::thread::id tid = std::this_thread::get_id();
+
+    arguments << mFile.substr(mFile.find_last_of('/') + 1) << ":"
+              << mLine << " (" << mFunc << ") [" << tid << "] " << mOutputStream.str();
+
+    unafrog::logger::instance().propagate_log(mLevel, arguments.str());
+}
+
+logstream &logstream::appendSpace()
+{
+    mOutputStream << ' ';
+    mOutputStream.flush();
+    return *this;
+}
+