-
Notifications
You must be signed in to change notification settings - Fork 232
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
Error messages are now printed using logger.error instead of System.error #203
Conversation
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.
These messages intentionally direct to stderr as any other command-line application. If you want to redirect when run as part of another application, perhaps you should call isatty
or some Java equivalent like System.console
?
@andrewgaul sorry I couldn't fully understand it. Can you explain a bit more about it? |
@andrewgaul Is this change ok? You can configure it through properties |
@andrewgaul any update on this pull request |
@kishore25kumar Please respond to my original review comment. |
@andrewgaul I didn't find anything similar to something you have specified. The best I could found is set the System.err to a different function and write it using a logger in the function. What to set for System.err is decided by a config flag. That is the change I have made in the pull request. |
@andrewgaul any suggestions on the pull request? I tried answering your question in previous comment |
235e291
to
d1cc178
Compare
@andrewgaul any suggestions on this pull request? |
You did not respond to my original review comments. I suggested looking at an This would allow the common case of an interactive user getting help text formatted as all other command line programs do while logging when Your approach, adding a flag to satisfy a single niche user, is not scalable from a complexity point of view. Have you instead considered redirecting output from the s3proxy executable, e.g., Why do you have such urgency for this logging-only patch? Just put it in your private branch if you are so committed to this. |
@andrewgaul I have updated pull request based on system.console exists or not. Sorry for the confusion as I don't have an idea about |
This improves over previous commits, but the first thing I tried does not log output correctly. Part of usage goes to logger and the rest goes to stderr:
What are you trying to accomplish with this pull request? Why do you want usage to go to logger? |
@andrewgaul
I figured out the issue. command line parser is not using the printstream directly instead it is using outputstream and wrapping this using a writer. So finally the ouputstream write function is called instead of printstream print function. I am looking into it. |
@andrewgaul Fixed the issue |
private static PrintStream createLoggerErrorPrintStream() { | ||
return new PrintStream(new LogOutputStream() { | ||
@Override | ||
protected void processLine(String s, int i) { |
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.
Instead of bringing in some unnecessary dependency, can't you just override write
? Or fix this upstream in args4j?
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.
@andrewgaul we can write but I should take care of all the scenarios. If I have to write something, it will be equivalent to that one at the end. Can I copy that file into s3proxy repo instead of adding the dependency? Is that ok?
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 will not accept cut and paste code. Also you need to at least open an issue against args4j if you do not provide a fix.
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.
Upstream issue kohsuke/args4j#149 and pull request kohsuke/args4j#150.
Using logger for printing messages make it consistent. And it also makes sure all logs go through same logging configuration (logback.xml) which has the s3 prefix in it. Using println will bypass it.