I\'m creating my own logging utility for my project, I want to create a function like iostream\'s std::cout, to log to a file and print to the console as well.
Here\
There's only one decent solution, and it's not simple, but it gets LOG(log_info) << "line 1\nline 2" << std::endl; correct.
You must implement a custòm std::ostreambuf. It's the only class that can reformat output after all the usual operator<< functions have been applied.
In particular, your stream buffer method overflow is called when you've got a bunch of characters to work on. You can now add your loglevel filtering, and reliably check for newlines in the formatted character stream.