-
Notifications
You must be signed in to change notification settings - Fork 212
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
Information messages should be written to stdout #3005
Conversation
The current behaviour is that `span.Info` messages are written to stderr instead of stdout. This is going against what is describe the [contributor document](https://github.com/getporter/porter/blob/main/CONTRIBUTING.md#logging). closes getporter#2889 Signed-off-by: Kim Christensen <kimworking@gmail.com>
It looks like to Porter info == debug, and so we're going to have to rework what is considered debug and what is "general" output. I wonder if there's some documentation on standards around this we can dig up. |
Yes it looks like that. I'm not sure what the best solution here would be. I haven't been able to find any real documentation on standards, only pointers in different places: Before I started to write this comment, I didn't really know where I stood in this question. But after formulating all this, I think I know 😄 I think there should be a difference between log messages and command output. Command outputs should always be written to stdout. Log messages are a bit harder, because based on the name, most people think about stderr as meant for errors. Then it boils down to the purpose of the log messages, or in this case the log messages sent through spans. In my head command output should never written through spans, only through porter/pkg/porter/parameters.go Lines 151 to 160 in aa7959f
porter/pkg/porter/credentials.go Lines 150 to 151 in aa7959f
If the way it is implemented in parameters is considered correct and we would accomendate the issue in #2889, that the default log level should be changed from into to either warn or error, to avoid informational "tracing" messages to the printed to stdout, and that the credentials command uses Sorry for this long comment, thinking about it got me started, please let me know what you think? |
I remember having discussions about log level and where to output before, this has been a weird topic. I think this can be broken into two parts, a "for now" fix, and a "long term bigger PR" fix (this way you didn't take something that seemed like a couple line change, and it grows to a couple hundred lines) - which is to swap over cmd output that is span.Infof into a fmt.Println (I don't love this long term, but again, band aid) - but to do this we must decide on what logging will look like long term (if we rip out spans, we should replace them with ctx, and then what are the changes needed to do that and run our logger throughout all the cmds) I would also love to chat about this in the community call this Thursday at 9AM MST - if you're able to make it I'd love your input there. :) Since this seems to be a user facing change I want to make sure there's nothing I'm not forgetting. |
@schristoff Sorry for the late response. |
These two places it is the actual output of the command, and it should not be suppressed by setting the log level higher than Info. Signed-off-by: Kim Christensen <kimworking@gmail.com>
Signed-off-by: Kim Christensen <kimworking@gmail.com>
Signed-off-by: Kim Christensen <kimworking@gmail.com>
Signed-off-by: Kim Christensen <kimworking@gmail.com>
What does this change
The current behaviour is that
span.Info
messages are written to stderr instead of stdout. This is going against what is describe the contributor document.With this change logs written with the log level
Info
will be written to stdout.What issue does it fix
Closes #2889
Notes for the reviewer
There were existing tests that verified that logs with
Info
level was written to stderr under some circumstances, these have been changed in this PR. But I have a hard time determining it breaks any real use cases.Checklist
Reviewer Checklist