Boost logo

Boost Users :

Subject: Re: [Boost-users] [iostreams] why doesn't file_sink flush?
From: Andy Schweitzer (a.schweitzer.grps_at_[hidden])
Date: 2009-05-04 20:21:27


eg wrote:
> Andrew Schweitzer wrote:
>> 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?
>>
>
>
> I am not sure if it is exactly your case, but you may wish to read the
> thread at:
> http://thread.gmane.org/gmane.comp.lib.boost.user/33355
>
> In particular, read the posts by Jonathan Turkanis (iostreams author).
> It may (or may not?) shed some additional light on flush and your needs.

Thanks, I've read that, but it doesn't directly answer my questions. In
particular, a) fstream flush seems to work fine, so I'm curious why
file_sink doesn't call it and b) given that you can't flush a file_sink
what is the appropriate implementation - it seems like there would be
one that is relatively straight-forward.


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