Display Console in Text?

Hi, I’m trying to display the console in my application within a textarea (from controlp5, but this question applies even without the library) in my application, so I can monitor my application’s console after it is packaged. Any way I can output the console to a string or even to a simple text file?

1 Like

I assume you are doing this for error checking? In general you should be able to catch errors, and display them with text. Check this out:

https://processing.org/reference/catch.html

Anything else can be displayed with text or however you need it to be displayed.

Hope this helps!

EnhancedLoop7

2 Likes

Technically, any time you print in the console, your are calling print. If you want to print in the console and in the text area for every message, then you could override the print function to do that. This approach works in case you are not working with multiple classes. Do you have intentions to also show errors from exceptions? Then you will need to use try-catch blocks as proposed by EnhancedLoop7.

Kf

2 Likes

This is great, do you have an example of what you mean by overriding the print function?

Ok, so overriding printl is not possible as it is an static method of PApplet. Instead, you could do this below.

Kf

String dashboardMsg;

void setup() {
  
  size(400,600);
  dashboardMsg="";  //Init
}

void draw() {
  
  text(dashboardMsg,width/2,height/2);
}

void mousePressed(){
  myPrint(""+millis());  // Used myPrint() instead of println
}


void myPrint(String msg) {
  dashboardMsg += msg+'\n';
  println(msg);
}


3 Likes

You are the best! This worked perfectly, just replaced all my println’s with myPrint.

1 Like