-
Notifications
You must be signed in to change notification settings - Fork 27
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
File log devices opened by mixlib-log should be closed. #13
Conversation
def loggers_to_close | ||
loggers_to_close = [] | ||
all_loggers.each do |logger| | ||
next unless logdev = logger.instance_variable_get(:"@logdev") |
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.
This seems like a bad idea. Needs a hell of a justification as a comment at least.
I have addeed comment to the code explaining the "bad idea". |
Ruby does not have a destructor concept so the opened files should be closed explicitely. The ruby logger which is used as a default logger here does not close logdevices it opened until #close method is called. When #rest! happens the logger instance gets destroyed but the #close method is not triggered. This patch should help to solve the problem described here: chef/chef#3435
I have just rebased branch on latest master and make PR ready to be merged. |
👍 |
Seems like a reasonable thing to do. @chef/client-core review? |
👍 |
1 similar comment
👍 |
def close! | ||
# try to close all file loggers | ||
loggers_to_close.each do |l| | ||
l.close rescue nil |
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.
Could we output any rescued errors to stderr? Seems like that would be nice for troubleshooting purposes
Ruby does not have a destructor concept so the opened files should be closed explicitly.
The Ruby Logger which is used as a default logger here does not close log devices it opened until #close method is called. When #rest! happens the logger instance gets destroyed but the #close method
is not triggered.
This patch should help to solve the problem described here: chef/chef#3435