Hello there,
Before I desribe the problem, I would just like to say that I am struggling with it all day basicaly and also that I am not very expirienced with c++ language.
So I am trying to write a singleton multithreaded logger application using standard libraries in c++. Using various tutorials and provided help i almost succed. The last thing I cannot do is auto new line. For example when using cout, if you want new line character you need to add std::endl or '\n':
Code:
std::cout << "some text" << std::endl;
But when for example using the qDebug() method (Qt) you dont need that, the new line character is added automatically. SO the cout code would e the same as:
Code:
qDebug() << "some text";
I really want the second functionality. So I have posted a similar question os Stack Overflow where an user got me the general idea of what to do, but I am having problem with the implementation. Here is the post: c++ - How to define an end of operator<< method? - Stack Overflow
Mu current way of doing new line is searching for the '\n' line every time the opearator<< is used which is unsufficient and the end of line sign can be forgotten easily.
Before any changes, my code looked and worked like this:
main.c
CLogger.h
CLogger.cpp
Now here i tried to apply the changes. Everything compiles but I get an error message when running the first method:
Code:
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::erase
Here is the code:
main.c
CLogger.h
CLogger.cpp
I dont know either this suggested method is the best, but the only one I know about so far.
I would really, really apriciate help in this topic. It means a lot to me to get this working. If there is any more information needed I will provide it asap.