For anyone that is interested, I have managed to achieve what I want.  I 
will be the first to declare its unelegant, but it does work.  The basic 
approach I have taken is to create my own implementation of console.log() 
as was suggested by others, by doing the following. I would add, I would 
have loved to have achieved this in a more elegant way, and in the C++ 
domain for cleanness, but the v8 API does not make it easy to do stuff like 
this, especially with my limited knowledge/experience of the v8 library/API 

In the C++ domain, I have created a new global function *coneole_write(int, 
const char*)* which deals with my application-specific needs to writing to 
my console, I attached this to the global object template. This being a 
global function, and because the process can handle multiple concurrent 
requests (and isolate per thread in our model), I needed to give the global 
function a context (aka which console socket to write to).   To do this I 
took a leaf out of the v8 design book and used thread local storage to hold 
my context information, this appears to be the way v8 holds its isolate 
context.  The global function takes an integer where 0=clear console, 
1=log, 2=info, 3=warn etc...

Now to get the console.log() functions working in the javascript domain, 
our implementation runs an init script, this is some JavaScript that 
provides some application-specific functions as well as dealing with 
initializing some global values.  I added the following JavaScript to this, 
which effectively re-defines the console object and gives me the subset I 
need for my application. 


* console = {*
* log: function(...args) {*
* console_write(1, args.join(", "));*
* },\r\n"*
* info: function(...args) {\r\n"*
* console_write(2, args.join(", "));*
* },*
* warn: function(...args) {*
* console_write(3, args.join(", "));*
* },*
* debug: function(...args) {*
* console_write(4, args.join(", "));*
* },*
* error: function(...args)*
* console_write(5, args.join(", "));*
* },*
* clear: function()*
* console_write(0)*
* }*
* }*

When I find a more elegant way of doing this IN THE C++ domain I will post 
again, but for now its working and I can move on.  Hopefully, others might 
find this useful. 
Gerry


-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to