-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log console output during replay to file #985 #76
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the appender usable after caught an exception here? What will happen when trying to write? |
||
} | ||
} | ||
|
||
~impl() | ||
|
@@ -137,18 +146,7 @@ namespace fc { | |
file_appender::file_appender( const variant& args ) : | ||
my( new impl( args.as<config>( FC_MAX_LOG_OBJECT_DEPTH ) ) ) | ||
{ | ||
try | ||
{ | ||
fc::create_directories(my->cfg.filename.parent_path()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this must be moved to impl::impl(), not simply removed. |
||
|
||
if(!my->cfg.rotate) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't walked all of the code, but if rotate == true, will removing this cause open() to be called twice (once here, and once in rotate_files()) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...and this shouldn't be removed. |
||
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(){} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_directories should happen before rotate_files.