Hi,

There are two changes to node that I'm considering contributing. Before I 
get started, I wanted to get some guidance on whether these things might 
ever be accepted into master.

*1. allow reassigning of console.log (and console.error, etc.) to other 
output streams*
*
*
Right now (as far as I can tell) the console logging functions always write 
to the original stdout or stderr streams that the process was passed at 
creation. I believe it would be nice to be able to reassign these to any 
stream object. The use case for me is when node is launched as a child 
process and stdout is used for IPC with the parent. It's annoying to write 
an IPC protocol that's tolerant to random strings getting written to stdout 
(via spurious console.logs in packages I didn't write).

An alternative to allowing this reassignment could be to have a call that 
sets all console logging functions to write to stderr. (Then stdout would 
be left free for IPC.) This might be drastically simpler.

A few questions:
  - Where should the API call go? The 'util' package? And, any guidance on 
what the API should be?
  - Right now, writes to stdout/stderr are usually blocking. Would we be 
opening up a can of worms by trying to have console.log write to streams in 
non-blocking ways?
  - If we consider this change, would we also change the logging functions 
in the 'util' package? Would we allow the user to switch each separately, 
or would console.log/util.log always write to the same place (and the same 
for console.error/util.error)?
  - Are there logging functions other than console.log/info/debug/error and 
util.debug/error/puts/print/log?


*2. allow enabling the V8 debugger programmatically (from a JS call)*
*
*
Right now, one can "hackily" enable the V8 debugger from JS by doing:
  process.kill(process.pid, "SIGUSR1");

However, this doesn't provide any feedback: the caller has no way of 
knowing if/when the debugger is enabled, nor any notification of why 
enabling failed (e.g. because port 5858 is already open in another 
process). Additionally, the caller can't control what port the debugger is 
opened on.

My use case for this is, again, in the situation where node is being run as 
a child process. The child process runs a server, and clients communicate 
over a websocket. I currently allow clients to enable debugging using the 
hack above (and then do the debugging using node-inspector). But, it would 
be nice to provide feedback to the client when it fails (and to allow the 
user to set alternate ports).

If we consider this change, what should the API be? How about something 
like: process.enableDebugger([port], [callback(err)])

Thanks!
  -- Joel

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to