Navigation Menu

Skip to content
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 · 2 comments

Comments

@tyukiand
Copy link

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:

https://github.com/tyukiand/processing/commit/3cfa89c4e360711dd4ac665f224771648744f309

(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
Copy link
Contributor

benfry commented Feb 13, 2016

Fixed for 3.0.2, see discussion in #4103.

@benfry benfry closed this as completed Feb 13, 2016
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants