-
Notifications
You must be signed in to change notification settings - Fork 453
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
Fix logger issues #955
Merged
Merged
Fix logger issues #955
Conversation
This file contains 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
Contributor
lamont-granquist
commented
Feb 28, 2017
•
edited
Loading
edited
i believe this gets the logic correct in that we want to configure the logger when we're coming from the command line but want to skip it when we're coming from chef or from other APIs that directly construct an Ohai::System object. i suspect this is what thom was trying to do by moving the Ohai::Log.init call into the Ohai::Application class (which avoids it being called entirely when Chef creates its Ohai::System object) here: https://github.com/chef/ohai/pull/942/files but that change broke the behavior where we were also supposed to skip the rest of the configure_logging method in Ohai::System when run under chef client. I tried going down the route of having the Ohai::Application class construct the Ohai::System object and then having it be the responsibility of that caller to do configure_logging work. However, I suspect that the initializer in Ohai::System does way too much and that the purpose of configuring the logger where it is, is that it must be initialized in the middle of object creation before it goes on and creates the Loader, the Runner, creates Hints and removes constants. So, I went the route of threading a flag through the initializer so that Ohai::System can know if its coming from the cli or not and behave appropriately. There's also quite a mess with the Ohai::Log class being passed around to the workstation loader, and it initializes itself at class loading time and Chef::Application will inject state into Ohai::Log. I think the eager initialization at class loading time is to not lose early messages when run from the cli, but it means the Ohai::Log object is always initialized, so that isn't useful for determining if we have come from the cli or not. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
26808a8
to
1da5486
Compare
@tas50 @cheeseplus i think this is more-or-less correct |
optional hashes and named arguments in ruby #FML |
tas50
previously requested changes
Feb 28, 2017
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.
Wanna add as simple test on that flag and look at the Travis failure
ruby doesn't like optional hashes combined with optional named parameters -- because hashes and kwargs get magically converted and ruby gets confused. plus fixed/added specs Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
@tas50 @cheeseplus once more unto the breach, dear friends, once more |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.