-
Notifications
You must be signed in to change notification settings - Fork 424
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
Provide a programmatic way to configure Picocli's TraceLevel #1471
Comments
Hi @ekinano, thanks for raising this. One could call |
Thanks for the quick reply @remkop. (If you're curious, we have a server for processing CLI-like arguments. We are leveraging Picocli's annotations to specify our "command" classes and its parser to parse those subcommands from the request. We would like to turn off Picocli's tracing to avoid filling our logs). |
@ekinano Thank you for the clarification. That makes sense. Will you be able to provide a pull request for this? |
This has been implemented and will be included in the 4.7.0 release. Details(from the release notes): From picocli 4.7.0, applications can programmatically set the trace level, and use tracing in custom components. In addition to setting system property CommandLine.tracer().setLevel(CommandLine.TraceLevel.INFO); The new public method class MyIntConverter implements ITypeConverter<Integer> {
public Integer convert(String value) {
try {
return Integer.parseInt(value);
} catch (NumberFormatException ex) {
CommandLine.tracer().info(
"Could not convert %s to Integer, returning default value -1", value);
return -1;
}
}
} |
The current pattern is to set the
picocli.trace
system property. It would be nice if there were a more programmatic way to do this, e.g. something likeFor context, we are currently using Picocli's parsing capabilities in an environment where a pattern like System.setProperty is heavily discouraged and requires a security exception.
The text was updated successfully, but these errors were encountered: