From c544b384da79d29cf6f3b60be176981cdac45eab Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Fri, 21 Sep 2018 12:14:33 +0300 Subject: [PATCH 1/2] Log console output during replay to file #985 --- src/log/file_appender.cpp | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/log/file_appender.cpp b/src/log/file_appender.cpp index 8e5c44cce..feeea628a 100644 --- a/src/log/file_appender.cpp +++ b/src/log/file_appender.cpp @@ -34,16 +34,25 @@ namespace fc { public: impl( const config& c) : cfg( c ) { - if( cfg.rotate ) - { - FC_ASSERT( cfg.rotation_interval >= seconds( 1 ) ); - FC_ASSERT( cfg.rotation_limit >= cfg.rotation_interval ); - + if( cfg.rotate ) + { + FC_ASSERT( cfg.rotation_interval >= seconds( 1 ) ); + FC_ASSERT( cfg.rotation_limit >= cfg.rotation_interval ); + rotate_files( true ); + } + try + { + fc::create_directories(cfg.filename.parent_path()); - _rotation_task = fc::async( [this]() { rotate_files( true ); }, "rotate_files(1)" ); - } + if(!cfg.rotate) + out.open( cfg.filename, std::ios_base::out | std::ios_base::app); + } + catch( ... ) + { + std::cerr << "error opening log file: " << cfg.filename.preferred_string() << "\n"; + } } ~impl() @@ -137,18 +146,7 @@ namespace fc { file_appender::file_appender( const variant& args ) : my( new impl( args.as( FC_MAX_LOG_OBJECT_DEPTH ) ) ) { - try - { - fc::create_directories(my->cfg.filename.parent_path()); - - if(!my->cfg.rotate) - my->out.open( my->cfg.filename, std::ios_base::out | std::ios_base::app); - - } - catch( ... ) - { - std::cerr << "error opening log file: " << my->cfg.filename.preferred_string() << "\n"; - } + } file_appender::~file_appender(){} From fa7faee63358e1c5518395b73433d5af285177a1 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Mon, 24 Sep 2018 22:09:22 +0300 Subject: [PATCH 2/2] fc::create_directories before rotate_files --- src/log/file_appender.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/log/file_appender.cpp b/src/log/file_appender.cpp index feeea628a..34a63a89f 100644 --- a/src/log/file_appender.cpp +++ b/src/log/file_appender.cpp @@ -34,20 +34,19 @@ namespace fc { public: impl( const config& c) : cfg( c ) { - if( cfg.rotate ) - { - FC_ASSERT( cfg.rotation_interval >= seconds( 1 ) ); - FC_ASSERT( cfg.rotation_limit >= cfg.rotation_interval ); - - rotate_files( true ); - } - 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_limit >= cfg.rotation_interval ); + + rotate_files( true ); + } else { out.open( cfg.filename, std::ios_base::out | std::ios_base::app); + } } catch( ... ) {