comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:a4671277546c
1 #include "logstream.h"
2 #include "logger.h"
3 #include <thread>
4
5
6 logstream::logstream(int line, const char pFile[], const char pFunc[], unafrog::log::LogLevel level) :
7 mFile(pFile),
8 mFunc(pFunc),
9 mLevel(level),
10 mLine(line)
11 {}
12
13 logstream::~logstream()
14 {
15 std::stringstream arguments;
16 std::thread::id tid = std::this_thread::get_id();
17
18 arguments << mFile.substr(mFile.find_last_of('/') + 1) << ":"
19 << mLine << " (" << mFunc << ") [" << tid << "] " << mOutputStream.str();
20
21 unafrog::logger::instance().propagate_log(mLevel, arguments.str());
22 }
23
24 logstream &logstream::appendSpace()
25 {
26 mOutputStream << ' ';
27 mOutputStream.flush();
28 return *this;
29 }
30