I enabled ConsoleExtension
for debugging scripts by calling installExtensions
. How can I capture the console output of QJSEngine?
Asked
Active
Viewed 230 times
0

Midiparse
- 4,701
- 7
- 28
- 48
-
`consloe.log()` ... ? – Mohammad Kanan Feb 04 '19 at 16:50
-
I know how I can print to stdout in JavaScript :). I don't know how I can read that from C++. – Midiparse Feb 05 '19 at 08:30
-
What do you mean by read that in C++ .. console logging id a debug tool .. – Mohammad Kanan Feb 05 '19 at 08:37
1 Answers
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