Boost logo

Boost :

Subject: [boost] [log] auto_flush not flushing?
From: Michael Caisse (boost_at_[hidden])
Date: 2010-06-11 23:32:41


I'm running on Vista and compiled with VC8. I have initialized the
backend like this:

-----------------------
typedef sinks::synchronous_sink< sinks::text_file_backend > sink_type;

boost::shared_ptr< sink_type > sink = boost::make_shared< sink_type >(
     keywords::file_name = "%Y%m%d_%H%M%S_%5N.log",
     keywords::open_mode = (std::ios::out | std::ios::app),
     keywords::auto_flush = true,
     keywords::rotation_size = rotate_size //
rotation size, in characters
  );

if( target_directory.empty() )
{
     target_directory = suggest_target_directory();
}

// Set up where the rotated files will be stored
sink->locked_backend()->set_file_collector( sinks::file::make_collector(
                             keywords::target =
target_directory, // where to store rotated files
                             keywords::max_size =
max_stored_size, // maximum total size of the stored files, in
bytes
                             keywords::min_free_space =
min_free_space // minimum free space on the drive, in bytes
                             ));
sink->locked_backend()->auto_flush(true);

// Upon restart, scan the target directory for files matching the
file_name pattern
sink->locked_backend()->scan_for_files();

typedef aux::add_common_attributes_constants< char > traits_t;
sink->locked_backend()->set_formatter(
     formatters::stream << formatters::attr< unsigned int
>(traits_t::line_id_attr_name())
     << " [" << formatters::date_time< boost::posix_time::ptime
>(traits_t::time_stamp_attr_name())
     << "] [" << formatters::attr<
attributes::current_thread_id::held_type >(traits_t::thread_id_attr_name())
     << "] [" << formatters::attr< severity_level
>(sources::aux::severity_attribute_name< char >::get())
     << "] " << formatters::message< char >()
     );
  
core::get()->add_sink(sink);
---------

Notice I have also added a call to auto_flush (for good measure with the
keyword didn't work (o; )

What happens is that the log file shows up after the program exits.
Since I was hoping to tail the file for some debug ... that isn't very
convenient.

Ideas of what I have done wrong?

TIA
michael

-- 
----------------------------------
Michael Caisse
Object Modeling Designs
www.objectmodelingdesigns.com

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