-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[cli] Don't log to STDOUT if debug flags are set #474
Conversation
f2d0f4b
to
331c025
Compare
@devplayer0 thanks for the PR. Shall we let the users control the behavior using |
331c025
to
bd2bfe5
Compare
@wing328 Normally that's what I'd do, but the problem is that there's no way to filter out the log output from the JSON when flags like With this change, I can do |
I think this is a good solution, but I think it would make more sense to put this behind an opt-in switch on the command line (something like I use the debug options often, and while I understand the use case… I would find it annoying to not see the other STDOUT messages when using the debug options. |
It makes sense that error messages should be written to STDERR and all others should be written to STDOUT (as shown in OpenAPITools#207). However, it would be convenient to parse the debugging output when the relevant flags are set. This change will disable logging to STDOUT and redirect all log messages to STDERR when any of the debug flags are set. (Resolves OpenAPITools#473)
Instead of automatically redirecting log messages to STDERR upon detection of the debug options, a new command line option (`--log-to-stderr`) will trigger this behavour, allowing the user to decide whether or not this is something they want.
bd2bfe5
to
5a543bc
Compare
@wing328 @jimschubert I have changed the behaviour so that log messages will only be redirected to STDERR if the For example, see the following commands: java -DdebugModels -jar openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java -i cellar.json -o /tmp/cellar > generate.log
java -DdebugModels -jar openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate --log-to-stderr -g java -i cellar.json -o /tmp/cellar > generate.json The contents of |
I've removed the breaking change label, as this is now a new option with no breaking change. |
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.
Looks good. No longer a breaking change, which is awesome.
I'll merge and update the README separately to list the new option.
@@ -199,8 +202,23 @@ | |||
description = "Skips the default behavior of validating an input specification.") | |||
private Boolean skipValidateSpec; | |||
|
|||
@Option(name = {"--log-to-stderr"}, |
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.
I think this option is much clearer, and has the benefit of not being a breaking change.
Updated README via a3e5edc |
* master: Fix problems in typescript jquery generator (#801) [PHP] Add gitignore to AbstractPhpCodegen (#765) Improve documentation for usage of a generator in an other jar (#817) Improve Symfony 4.1 compatibility (#830) 📝 Updating 'help generate' switches in README [cli] Don't log to STDOUT if debug flags are set (#474) [gradle-plugin] README notes on multiple specs (#847) Added server variable support (#816) fix erlang optiona/required parameters (#829) [Java][Rest-assured] Fix generated javadoc and "swagger-annotations" improvement (#831)
@devplayer0 thanks for the contribution, which has been included in the 4.0.0-beta release: https://twitter.com/oas_generator/status/1079727020374806529. Happy New Year and looking forward to more collaboration and contributions in 2019! |
It makes sense that error messages should be written to STDERR and all others should be written to STDOUT (as shown in OpenAPITools#207). However, it would be convenient to parse the debugging output when the relevant flags are set. This change will disable logging to STDOUT and redirect all log messages to STDERR when any of the debug flags are set. (Resolves OpenAPITools#473)
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,3.1.x
,4.0.x
. Default:master
.Description of the PR
It makes sense that error messages should be written to STDERR and
all others should be written to STDOUT (as shown in #207). However, it
would be convenient to parse the debugging output when the relevant
flags are set.
This change will disable logging to STDOUT and redirect all log messages
to STDERR when any of the debug flags are set. (Resolves #473)