fc::create_directories before rotate_files

This commit is contained in:
Valera Cogut 2018-09-24 22:09:22 +03:00
parent c544b384da
commit fa7faee633

View file

@ -34,21 +34,20 @@ namespace fc {
public: public:
impl( const config& c) : cfg( c ) impl( const config& c) : cfg( c )
{ {
try
{
fc::create_directories(cfg.filename.parent_path());
if( cfg.rotate ) if( cfg.rotate )
{ {
FC_ASSERT( cfg.rotation_interval >= seconds( 1 ) ); FC_ASSERT( cfg.rotation_interval >= seconds( 1 ) );
FC_ASSERT( cfg.rotation_limit >= cfg.rotation_interval ); FC_ASSERT( cfg.rotation_limit >= cfg.rotation_interval );
rotate_files( true ); rotate_files( true );
} } else {
try
{
fc::create_directories(cfg.filename.parent_path());
if(!cfg.rotate)
out.open( cfg.filename, std::ios_base::out | std::ios_base::app); out.open( cfg.filename, std::ios_base::out | std::ios_base::app);
} }
}
catch( ... ) catch( ... )
{ {
std::cerr << "error opening log file: " << cfg.filename.preferred_string() << "\n"; std::cerr << "error opening log file: " << cfg.filename.preferred_string() << "\n";