Closed pofider closed 8 years ago
i agree, but since we're using stdout for communication with node i think things can be really messy for extracting messages from phantomjs
.
Replacing standard console.log
in phantomjs script with my own one seems to me like a solution.
var messages = [];
console.log = function(m) {
messages.push(m);
}
system.stdout.write(JSON.stringify({
messages: messages,
numberOfPages: body.numberOfPages
}));
Then I can read the result in the node through JSON.parse. This gives me the nice object I can work with.
{"messages":["ReferenceError: Can't find variable: foo\n"," file:///C%3A%5CUsers%5CJANBLA~1%5CAppData%5CLocal%5CTemp%5Cjsreport-temp%5C383fddd0-ccfd-11e5-a1d4-334053d951c1html.html:4 in global code"],"numberOfPages":1}
What you think?
Another question is how to display this actually in the jsreport. I can provide it in the response object to the node.js callers, that is fine. I can also provide an info in the response header. However how to show this in the studio? I was thinking that the best is to have an option flag in the jsreport studio phantom settings instructing recipe to return the phantomjs output instead of pdf. Something like phantom.debug = true
.
looks good to me, i don't find any drawback doing that.
However how to show this in the studio? I was thinking that the best is to have an option flag in the jsreport studio phantom settings instructing recipe to return the phantomjs output instead of pdf. Something like phantom.debug = true.
sounds good, what about when an error happen? the message from phantomjs will be included in the studio too? showing nodejs stack trace along with the message from phantomjs sounds good.
Yes, that would be nice. I'll try to provide it. Thank you.
Released in 0.4.0
Currently we are just ignoring the ouput from phantomjs. The output can contain very important messages which should be provided to the caller.