-
Notifications
You must be signed in to change notification settings - Fork 77
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
(VANAGON-57) inform on STDERR, not STDOUT #474
Conversation
I'm not in love with this approach, but it's not drastically different than how Vanagon handled notification/informing users of state/status previously. The only difference is now the output is explicit, and can be more easily/predictably filtered. I think that this is a hold-over bandaid until we've got a better logging/notification system in place in Vanagon but it should address the concerns in VANAGON-57.
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.
@mckern there are several things that I saw and looked like they should go to stdout, not stderr.
Other than that everything looks good
@@ -78,7 +78,7 @@ def file | |||
# | |||
# @raise [RuntimeError] an exception is raised if the sum does not match the sum of the file | |||
def verify # rubocop:disable Metrics/AbcSize | |||
puts "Verifying file: #{file} against sum: '#{sum}'" | |||
$stderr.puts "Verifying file: #{file} against sum: '#{sum}'" |
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 it should go to stdout
@@ -92,7 +92,7 @@ def download(target_url, target_file = nil, headers = { "Accept-Encoding" => "id | |||
uri = URI.parse(target_url.to_s) | |||
target_file ||= File.basename(uri.path) | |||
|
|||
puts "Downloading file '#{target_file}' from url '#{target_url}'" | |||
$stderr.puts "Downloading file '#{target_file}' from url '#{target_url}'" |
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.
Also should go to stdout
@@ -148,7 +148,7 @@ def render | |||
raise Vanagon::Error, "Project requires a version set, all is lost." | |||
end | |||
|
|||
puts "rendering Makefile" | |||
$stderr.puts "rendering Makefile" |
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.
should go to stdout
@@ -117,7 +117,7 @@ def run # rubocop:disable Metrics/AbcSize | |||
|
|||
@engine.startup(@workdir) | |||
|
|||
puts "Target is #{@engine.target}" | |||
$stderr.puts "Target is #{@engine.target}" |
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.
should go to stdout
@@ -43,8 +43,8 @@ def filter_out_components(only_build) | |||
# flatten all the results in to one array and set project.components to that. | |||
@project.components = only_build.flat_map { |comp| @project.filter_component(comp) }.uniq | |||
if @verbose | |||
puts "Only building:" | |||
@project.components.each { |comp| puts comp.name } | |||
$stderr.puts "Only building:" |
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.
should go to stdout
@@ -56,7 +56,7 @@ def read_vanagon_token(path = "~/.vanagon-token") | |||
absolute_path = File.expand_path(path) | |||
return nil unless File.exist?(absolute_path) | |||
|
|||
puts "Reading vmpooler token from: #{path}" | |||
$stderr.puts "Reading vmpooler token from: #{path}" |
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.
should go to stdout
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 is exactly the message that is screwing us up in CI by being printed to stdout.
@@ -70,7 +70,7 @@ def read_vmfloaty_token(path = "~/.vmfloaty.yml") | |||
absolute_path = File.expand_path(path) | |||
return nil unless File.exist?(absolute_path) | |||
|
|||
puts "Reading vmpooler token from: #{path}" | |||
$stderr.puts "Reading vmpooler token from: #{path}" |
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.
should go to stdout
@@ -119,7 +119,7 @@ def teardown | |||
) | |||
if response and response["ok"] | |||
Vanagon::Driver.logger.info "#{@target} has been destroyed" | |||
puts "#{@target} has been destroyed" | |||
$stderr.puts "#{@target} has been destroyed" |
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.
should go to stdout
@@ -28,7 +28,7 @@ def initialize(banner, options = []) | |||
end | |||
|
|||
opts.on('-h', '--help', 'Display help') do | |||
puts opts | |||
$stdout.puts opts | |||
exit 1 |
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.
unrelated, but why would displaying help return 1 and not 0?
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.
You know, I actually wonder who did that too. Asking for help and getting help means it did what you asked for. I'll fix that in this PR.
@@ -228,7 +228,7 @@ def identifier(ident) | |||
# | |||
# @param name [String] name of component to add. must be present in configdir/components and named $name.rb currently | |||
def component(name) | |||
puts "Loading #{name}" if @project.settings[:verbose] | |||
$stderr.puts "Loading #{name}" if @project.settings[:verbose] |
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.
should go to stdout
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.
Sorry, I didn't mean to approve, I want changes unless you disagree
@mcdonaldseanp this is in response to https://github.com/puppetlabs/ci-job-configs/pull/2649. Not sure if you were following that conversation. Do you have another approach? |
@mcdonaldseanp So. Let's talk about STDOUT/STDERR paradigms. Errors go to STDERR, everything else goes to STDOUT, right? BUT! Because we've only got two default output streams (technically you have a ton more, but Here's a
Let's redirect STDOUT:
Huh. What changed? Nothing meaningful, because the informative but not-essential output was written to STDERR in light of a lack of STDINFO or STDNICETOKNOW or STDOHTHATMAKESSENSE. I suspect that we'll often end up doing the same thing in Vanagon, and that's why so many of these informative-but-not-essential messages were redirected to STDERR instead of STDOUT. So, with that background, where do you think some of those messages should go? |
@mckern yeah, I get why we would put these things in stderr. It bothers me to push everything to stderr since most of it is just verbose stdout but we currently don't have a great alternative. Is there work ticketed to get more powerful logging in vanagon? Like the ability to specify things will go to stdout when -v/--verbose are specified and either a logfile or nowhere otherwise? |
What I would like to see eventually is the ability to do something like:
And everything that calls that will go to stdout /if/ the user specifies -v/--verbose |
Do we not have any standard logging utility for Ruby? The C++ projects all use the one in Leatherman, which allows this. |
CLA signed by all contributors. |
This seems reasonable I think. Mostly worried about what this might break. Have you built anything with this? |
Will merge after Vanagon 0.11.3 release... hopefully today |
I'm not in love with this approach, but it's not drastically different
than how Vanagon handled notification/informing users of state/status
previously. The only difference is now the output is explicit, and can
be more easily/predictably filtered. I think that this is a hold-over
bandaid until we've got a better logging/notification system in place
in Vanagon but it should address the concerns in VANAGON-57.
As is, I'm not wedded to this approach and I'd love to hear any ideas anyone else has.