How to put console.log in V8 javascript file?

492 views
Skip to first unread message

madana gopal

unread,
Mar 6, 2015, 7:00:18 AM3/6/15
to v8-u...@googlegroups.com
Hi,

We want to give console.log to print the string being passed as input to JS functions in V8. Eg..Encode() function in uri.js. When we add such statement, we are getting compilation error during execution. Please tell how to add those statements in any of V8 javascript file.

Regards,
Madan

Flying Jester

unread,
Mar 6, 2015, 8:06:42 AM3/6/15
to v8-u...@googlegroups.com
The `console' object is not a part of JavaScript. It's standard in Web JS, but no JS engine on its own provides that. If you want some way to log from JS, you will have to do it yourself.

Richard Emerson

unread,
Jul 14, 2015, 10:38:56 AM7/14/15
to v8-u...@googlegroups.com

Forgive me if this is a total noob question, but what is the nearest equivalent in 'bare' V8?  I naively assume that there must be some way to write to stdout/stderr from JS running in V8, but is that actually the case?  If we were to do it ourselves, how might we do that - is it even possible without adding in some native code?

Thanks and regards,
Richard


Andreas Rossberg

unread,
Jul 14, 2015, 10:47:06 AM7/14/15
to v8-u...@googlegroups.com
On 14 July 2015 at 16:38, Richard Emerson <richard...@gmail.com> wrote:

Forgive me if this is a total noob question, but what is the nearest equivalent in 'bare' V8?  I naively assume that there must be some way to write to stdout/stderr from JS running in V8, but is that actually the case?  If we were to do it ourselves, how might we do that - is it even possible without adding in some native code?

There is nothing in the V8 engine as such. But the simple d8 shell that comes with it has a 'print' function. But it's the embedder who has to provide such a thing.

/Andreas

Reply all
Reply to author
Forward
0 new messages