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

processing-java violates "Rule of Silence" by printing debug information to stdout #4098

Closed
tyukiand opened this Issue Nov 3, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@tyukiand

tyukiand commented Nov 3, 2015

Processing is great if one wants to take some input data and transform it into an image or an animation. Moreover, I think it can be also very useful for the other direction, namely: take an image as input, analyse it, print the result as text. However, processing-java always produces some debug output, which has to be removed either by stream redirection or some other tools like awk or sed.

Example

void setup() {
  /* load some images, grab pixels, do some calculations */
  println("Very useful result = " + 42);
  exit();
}

If I call it as follows:

processing-java --sketch="nameOfTheSketch" --run

the expected output would be:

Very useful result = 42

but the actual output is:

Listening for transport dt_socket at address: 8651
Very useful result = 42
Finished.

Problem

There are two unexpected lines printed to stdout: the first line is the cryptic message "Listening for transport dt_socket at address:" followed by a random 4-digit number. The last message is always trivially true.

Proposed solutions

Short solution
Eliminate both messages altogether. In processing/java/src/processing/mode/java/Commander.java delete the line

  systemOut.println("Finished.");

and in processing/java/src/processing/mode/java/runner/Runner.java
replace the line

String jdwpArg = "-agentlib:jdwp=transport=dt_socket,address=" + portStr + ",server=y,suspend=y";

by

String jdwpArg = "-agentlib:jdwp=transport=dt_socket,address=" + portStr + ",server=y,suspend=y,quiet=y";

This solution might break some existing code (maybe someone already uses this in a script, and drops the first line of the output).

Long(er) solution
Add a --quiet flag to processing-java. This is not complicated either, I've implemented it here:

tyukiand@3cfa89c

(link to commit)

Now, one can call processing-java as follows:

processing-java --sketch="nameOfTheSketch" --quiet --run

and it would produce only:

Very useful result = 42

This does not break any existing scripts that use processing-java, but it would make the STDOUT more useful than it is right now.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Feb 13, 2016

Member

Fixed for 3.0.2, see discussion in #4103.

Member

benfry commented Feb 13, 2016

Fixed for 3.0.2, see discussion in #4103.

@benfry benfry closed this Feb 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment