0

I enabled ConsoleExtension for debugging scripts by calling installExtensions. How can I capture the console output of QJSEngine?

Midiparse
  • 4,701
  • 7
  • 28
  • 48

1 Answers1

0

If you want to capture the output of the script back into your C++ program, its best if you don't use the ConsoleExtension - instead expose an API to allow the script to call your implementation directly to "print to standard output".

Take for example what Plasma ScriptEngine does - it exposes a print() method on the globalObject that scripts can use to "print output". In Plasma that would be printed out from the plasmashell process and captured by various logging mechanisms, but you can do what you want with the input to your print() function. Your global object interface can even mimic console.log().

Guss
  • 30,470
  • 17
  • 104
  • 128