I would like to see a log file that will contain exactly the same data as the std::cout
prints to console (without hiding output), so anything displayed in windows console/linux terminal will be copied to file output.log
, without using OS-specific tools (like operator >
in bash or tee
).
The only one solution i see is to create class that will "cache" messages storing them temporarily in stringstream
and then "flush" it to both (or more) streams, but this has disadvantage for my case and not suitable because i need my <<
calls to output cout
exactly at the moment of their execution.
Is this possible? I don't see anything in standard library suitable for this task.