Implementing a debugging/console into my Juce application

Hi,

I’m trying to create a UI element that will be used to display debug tracing from my application. Think of it as an IDE’s console where std::cout and other messages will be continuously written to.

I’ve played around with the TextEdit component but that is very slow as the text buffer grows.

Ideally, I could set a total buffer size that would be displayed. I also want to be able to copy the buffered text to the clipboard.

Any recommendations about what Juce components might work well for this?

Thanks,
bob

I think, TextEditor is your best bet. How are you adding the text?

OK. This works better…

std::string tmp = “hello world”;

editor->setCaretPosition(editor->getTotalNumChars());
editor->insertTextAtCaret(tmp);

My original implementation:

juceString newStringToAppendToEnd = “hello world”;

juce::String str = textEdit->getText();
textEdit->setText(str + tmp);

Is there a more efficient way of appending text to the end?

Not sure if it is exactly what you want, but I implemented a component that displays stdout/stderr prints. It also uses a TextEditor for that. Maybe it might help you… Just build the example project and check out its functionality!

3 Likes

Hi,

I found your thread while searching for a way to integrate a built-in logger component into my standalone JUCE application. I successfully implemented your code, and I appreciate how smoothly it worked right out of the box!

However, I’ve encountered an issue: the logging functions properly only when I run the application from the terminal using ./my_app.exe. When I launch the executable by double-clicking it or from Visual Studio, it only logs stderr messages and fails to capture any stdout messages.

Do you have any insights into why this might be happening? I would greatly appreciate any guidance you could provide. Thank you once again for your excellent work!

Edit: This only happens on Windows. Linux and MacOS are working flawlessly.