I'm running an OpenGL program, and have setup a basic error reporting system which I'm using to call a function which uses fprintf
and prints to stderr
. On top of this, I have several fprintf
's inline with the rest of my code.
I also have a fstream
setup which allows me to print directly to the log file of my choice. However I don't want to duplicate every line in which I use fprintf
to include printing to the log.
Is there a way I can set my stderr
and stdout
to also point to the log, or can I create my own?
I'm seeing other questions like this and this, and the answers seem to use a tee
and wtee
function. The second one states that tee
only works on UNIX. Since I'm doing this on Visual Studio 2015 on Windows, so this isn't going to be an option. However I am trying to cross-platform my application, so I'm looking for a cross-platform solution. I'm not too worried about Linux at this stage, as long as it works on MacOS and Windows.