I want to write a functionality like:
DEBUG_LOG<<"append" << 123 <<" float=" <<123.432 << std::endl;
the << operator for this looks like:
Logger& operator<<(const T& message)
{
if(message == std::endl)
{
flushBuffer();
return *this;
}
std::stringstream ss;
ss << message;
writeToBuffer(ss.str());
return *this;
}
Now, this definitely does not compile since the if statement has a compilation error.
The flushBuffer() writes one line into a file and clears the buffer, writeToBuffer() appends to the buffer. Can you please suggest something in place of the if statement? Basically I need to know when a newline has been received accordingly the other two functions will be called.