Boost Users :
Subject: [Boost-users] [iostreams] why doesn't file_sink flush?
From: Andrew Schweitzer (a.schweitzer.grps_at_[hidden])
Date: 2009-05-04 13:56:55
I'm trying to chain debugging logs together with a filtering_ostream.
I've discovered that I need to call flush() on the filtering_ostream to
get characters to appear in console in a timely fashion. This flush()
call doesn't causes the file to be flushed. After some digging, I've
discovered that the boost::iostreams::file_sink doesn't have the
flushable_tag (or implement flush). std::fstream does have a flush
function, and if I use it directly (not chained into a
filtering_ostream), the flush call works as you might expect.
So what is the appropriate way of implementing this? Chaining multiple
logs together seems like a great way to use iostreams library. And out
of curiosity, why doesn't file_sink implement flushable_tag?
Here is the code I was using:
int main(int argc, char** argv)
using namespace std;
using namespace boost;
using namespace boost::iostreams;
int i = 0;
fo << i << " ";
//without this, I don't see "one print / second"
//with it, I only see them on cout, but not in out.txt.
xt.sec += 1;
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net