F
Fraser Ross
My program outputs to cout and I want it to output to a LOG file as well.
Is there a simple way to do that?
Fraser.
Is there a simple way to do that?
Fraser.
Fraser Ross said:My program outputs to cout and I want it to output to a LOG file as well.
Is there a simple way to do that?
#define PRINT(xxx) std::cout << "Something to log and print"; \
out1 << "Something to log and print";
Fraser Ross said:My program outputs to cout and I want it to output to a LOG file as well.
Is there a simple way to do that?
Sharad Kala said:You could also use Macro trick to get this done, something like -
#define PRINT(xxx) std::cout << "Something to log and print"; \
out1 << "Something to log and print";
Old said:This would be bad if xxx had side effects.. how about:
struct tee_stream
{
template<typename T>
tee_stream &operator<< (T const &t) {
std::cout << t;
other_stream << t;
return *this;
}
};
Fraser Ross said:My program outputs to cout and I want it to output to a LOG file as well.
Is there a simple way to do that?
Rolf Magnus said:Try:
tee_stream mystream;
mystream << std::endl;
Interesting, why doesn't this work exactly?
Fraser Ross said:I would try your suggestion if I could get the Boost libraries installed.
Fraser Ross said:I have made improvements to the igzstream and ogzstream classes available
from the link to "zlib C++ wrapper" at the zlib home page. They fix a bug
with gzstreambuf::close() as well as mainly minor improvements. If you are
interested in seeing the 2 files I could send them by email.
Fraser Ross said:My program outputs to cout and I want it to output to a LOG file as well.
Is there a simple way to do that?
Fraser.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.