|
Boost : |
Subject: [boost] [log] Wide Character Backend file problems
From: Sivaram Kannan (siva.devel_at_[hidden])
Date: 2010-08-15 04:31:20
Hi,
I was trying to create a log file with wide character support. Similar code
with normal character support works well, where as for wide character
support the log file itself is not getting created. Here is the code for
both types. Can someone tell me, what am I missing with the wide character
type. The code compiles, but the log file alone is not getting created when
the program is run.
//Wide Character version
void Log_Init()
{
boost::function< void (std::wostream&, boost::log::wrecord const&) >
formatter =
boost::log::formatters::wstream
<< boost::log::formatters::date_time< boost::posix_time::ptime
>(L"TimeStamp") << L" *"
<< boost::log::formatters::attr< int >(L"Severity") << L"* " <<
boost::log::formatters::wmessage();
boost::shared_ptr<
sinks::synchronous_sink<boost::log::sinks::wtext_file_backend>
> sink = boost::log::winit_log_to_file(
keywords::file_name = L"C:\\BMR\\Logs\\bmr.log", // file name
pattern
keywords::rotation_size = 1 * 1024 * 1024, // rotate files
every 1 MiB...
keywords::open_mode = std::ios_base::app,
keywords::auto_flush = true
);
sink->locked_backend()->set_formatter(formatter);
// Register common attributes
boost::log::add_common_attributes();
}
//Normal Character version
void Log_Init()
{
boost::function< void (std::ostream&, boost::log::record const&) > formatter
=
boost::log::formatters::stream
<< boost::log::formatters::date_time< boost::posix_time::ptime
>("TimeStamp") << " *"
<< boost::log::formatters::attr< int >("Severity") << "* " <<
boost::log::formatters::message();
boost::shared_ptr<
sinks::synchronous_sink<boost::log::sinks::text_file_backend>
> sink = boost::log::init_log_to_file(
keywords::file_name = "C:\\BMR\\Logs\\bmr.log", // file name pattern
keywords::rotation_size = 1 * 1024 * 1024, // rotate files
every 1 MiB...
keywords::open_mode = std::ios_base::app,
keywords::auto_flush = true
);
sink->locked_backend()->set_formatter(formatter);
// Register common attributes
boost::log::add_common_attributes();
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk