Repository navigation
Don't panic when writing to the log file fails - #1265
Open
ajaysehwal wants to merge 1 commit into
Open
ajaysehwal wants to merge 1 commit into
ajaysehwal wants to merge 1 commit into
Conversation
The file logger reopened the log file for each record and `expect`ed both the open and the write to succeed. Any I/O error, e.g. a full disk or a removed log directory, therefore panicked in whatever thread was logging, which could be a background task holding locks. Print the error to stderr instead and drop the record, as we already do when setting up the log file fails.
|
I've assigned @tnull as a reviewer! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The file logger reopens the log file for each record and
expects both the open and the write to succeed. Any I/O error (a full disk, a removed log directory, changed permissions) therefore panics in whatever thread is logging, which can be a background task holding locks. Withpanic = "abort"this kills the host process.This prints the error to stderr and drops the record instead, as we already do when setting up the log file fails in
Logger::new_fs_writer. The file is still reopened per record, so external log rotation keeps working.Testing
Added
log_file_write_errors_do_not_panic, which removes the log directory after creating the logger and then logs a line. It panics without this change and passes with it.