summaryrefslogtreecommitdiff
path: root/src/node.cc
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-08-21 15:36:50 -0700
committerisaacs <i@izs.me>2013-09-02 20:15:40 -0700
commit906a175a0b40fc56dfafbe0929e4fbbb4df68ff2 (patch)
treec60680a4104c4838034626f124c49bbd4c8bc012 /src/node.cc
parentcb53cfd8b58907074af464b0a94a550d0969b6b7 (diff)
downloadnode-new-906a175a0b40fc56dfafbe0929e4fbbb4df68ff2.tar.gz
process: Add internal _rawDebug() method
This is useful when we need to push some debugging messages out to stderr, without going through the Writable class, or triggering any kind of nextTick or callback behavior.
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc
index c26c1d2384..3f49ec4edb 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -2525,6 +2525,22 @@ static void SignalExit(int signal) {
}
+// Most of the time, it's best to use `console.error` to write
+// to the process.stderr stream. However, in some cases, such as
+// when debugging the stream.Writable class or the process.nextTick
+// function, it is useful to bypass JavaScript entirely.
+static void RawDebug(const FunctionCallbackInfo<Value>& args) {
+ HandleScope scope(node_isolate);
+
+ assert(args.Length() == 1 && args[0]->IsString() &&
+ "must be called with a single string");
+
+ String::Utf8Value message(args[0]);
+ fprintf(stderr, "%s\n", *message);
+ fflush(stderr);
+}
+
+
void Load(Handle<Object> process_l) {
HandleScope handle_scope(node_isolate);
@@ -2581,6 +2597,8 @@ void Load(Handle<Object> process_l) {
// thrown during process startup.
try_catch.SetVerbose(true);
+ NODE_SET_METHOD(process_l, "_rawDebug", RawDebug);
+
Local<Value> arg = process_l;
f->Call(global, 1, &arg);
}