My program uses cout for all of its output. Currently the user can specify a silent mode that points cout into a log file. I'd like to have an option where cout will print as usual and to a log file. Possible?
Thanks.
My program uses cout for all of its output. Currently the user can specify a silent mode that points cout into a log file. I'd like to have an option where cout will print as usual and to a log file. Possible?
Thanks.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Not really. You could (possibly) inherit from ostream and create your own type, that outputs to both cout and a logfile, but generally it is probably better to make a function that replaces your regular cout operations.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Feared so. Thanks.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Using the C output functions this is actually a rather easy task. Perhaps what you could do is see if you can simply redirect cout doing something similar. Your code would not likely be very portable but I betcha that you can whip up something.
Better late than never....bump with solution: Output string to both console and file at the same time
gg
Ah excellent. I figured the solution went that way but never put the time into writing (learning) the streambuf. Thanks, codeplug.
"If you tell the truth, you don't have to remember anything"
-Mark Twain