Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Add support for --console-to-stderr switch.
Browse files Browse the repository at this point in the history
If present, forces console.log() and console.info() to use stderr for output,
rather than current default of stdout.

Purpose is to tolerate simultaneous use of common JavaScript idioms regarding
use of console API and standard unix idioms regarding use of stdout vs. stderr.


Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
  • Loading branch information
jonseymour committed Apr 21, 2011
1 parent f5fd098 commit 2daeba0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/node.cc
Expand Up @@ -104,6 +104,7 @@ static Persistent<String> emit_symbol;


static char *eval_string = NULL;
static char *console_selector = NULL;
static int option_end_index = 0;
static bool use_debug_agent = false;
static bool debug_wait_connect = false;
Expand Down Expand Up @@ -2037,6 +2038,11 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
process->Set(String::NewSymbol("_eval"), String::New(eval_string));
}

// --console-to-stderr
if (console_selector) {
process->Set(String::NewSymbol("_console_selector"), String::New(console_selector));
}

size_t size = 2*PATH_MAX;
char execPath[size];
if (Platform::GetExecutablePath(execPath, &size) != 0) {
Expand Down Expand Up @@ -2221,6 +2227,9 @@ static void ParseArgs(int argc, char **argv) {
}
argv[i] = const_cast<char*>("");
eval_string = argv[++i];
} else if (strcmp(arg, "--console-to-stderr") == 0) {
console_selector="stderr";
argv[i] = const_cast<char*>("");
} else if (strcmp(arg, "--v8-options") == 0) {
argv[i] = const_cast<char*>("--help");
} else if (argv[i][0] != '-') {
Expand Down

0 comments on commit 2daeba0

Please sign in to comment.