Boost logo

Boost :

From: martin.ecker_at_[hidden]
Date: 2005-06-30 02:52:50


Hello,

Greg Landrum wrote:
> I'm trying to get the logs to dump their output to std:cerr immediately:
[snip]
> However, the output from running this is always something like:
> 1
> 3
> [14:56:35] 2
> [14:56:35] 4
>
> So the logger output is "late". Is there some flag I can set (or
> appender I can use) that will force output to go to the target streams
> immediately or is this outside the design of the logging library?

I also happened to stumble accross this. The problem is that log caching
is
turned on initially and you have to explicitly turn it off.
Basically, it should work if you change your code to this:

int main(){
 logging::add_modifier("cerrLog",logging::prepend_time("[$hh:$mm:$ss] "),
                              logging::DEFAULT_INDEX-10);
 logging::add_appender("cerrLog",write_to_cerr,logging::DEFAULT_INDEX+1);

 // now flush the log cache; this also turns off log caching, so from now
 // on all log output is not cached, but written out immediately
 logging::flush_log_cache();

 std::cerr << "1" << std::endl;
 BOOST_LOG(cerrLog) << "2" << std::endl;
 std::cerr << "3" << std::endl;
 BOOST_LOG(cerrLog) << "4" << std::endl;
}

See the docs for more details on this.

Best Regards,
Martin

TAB Austria
Haiderstraße 40
4052 Ansfelden
Austria
Phone: +43 7229 78040-218
Fax: +43 7229 78040-209
E-mail: martin.ecker_at_[hidden]
http://www.tab.at


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk