Open nathanduchesne opened 4 months ago
Thanks Nathan! I think this deliberate choice of instantiating from FileDescriptor.err
is to force it to display it on the screen, if stderr
is used for something else (which is likely when used within a build system). Maybe we could add a switch somewhere so that the stream can be customized?
I am experiencing different program behaviour when running this code
ProgressBar pb = new ProgressBar(name, 100);
or this code:
ProgressBar.builder().setTaskName(progressBarName).setInitialMax(progressBarMaxCapacity).setStyle(ProgressBarStyle.ASCII).build();
What I was expecting: Everything works the same, except case 2 has a different display, since we no longer use Unicode.
What happens: When using the builder, the default PrintStream is not
System.err
, but instead is(see Utils.java, line 20-23)
Why this may be a problem: My code redirects certain streams (typically System.err) to other streams, and hence uses System.setErr() to redirect it. Because of this inconsistency, I can no longer do so. Additionally, I am uncertain as to what benefits you gain from instantiating the PrintStream the way you do so in the above code, as opposed to using System.err directly.
What can easily be done :)
Would you be open to changing
PrintStream real = new PrintStream(new FileOutputStream(FileDescriptor.err));
withPrintStream real = System.err;
This would make the whole code consistent. Let me know what you think and if you want me to make a pull request for this change!
Best, Nathan