:%s/sys.puts/console.log/g
authorRyan Dahl <ry@tinyclouds.org>
Thu, 24 Jun 2010 00:40:51 +0000 (17:40 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Thu, 24 Jun 2010 03:05:29 +0000 (20:05 -0700)
and there was much rejoicing

92 files changed:
benchmark/http_simple.js
benchmark/run.js
bin/node-repl
doc/api.markdown
doc/index.html
src/node.js
test/disabled/test-cat.js
test/disabled/test-dns.js
test/disabled/test-eio-race3.js
test/disabled/test-http-big-proxy-responses.js
test/disabled/test-http-head-request.js
test/disabled/test-http-stress.js
test/disabled/test-remote-module-loading.js
test/disabled/tls_client.js
test/disabled/tls_server.js
test/fixtures/b/c.js
test/fixtures/child_process_should_emit_error.js
test/fixtures/cycles/folder/foo.js
test/fixtures/cycles/root.js
test/fixtures/exit.js
test/fixtures/print-10-lines.js
test/message/2100bytes.js
test/message/hello_world.js
test/message/undefined_reference_in_new_context.out
test/pummel/test-child-process-spawn-loop.js
test/pummel/test-http-client-reconnect-bug.js
test/pummel/test-keep-alive.js
test/pummel/test-net-many-clients.js
test/pummel/test-net-pause.js
test/pummel/test-net-pingpong-delay.js
test/pummel/test-net-pingpong.js
test/pummel/test-net-throttle.js
test/pummel/test-net-timeout.js
test/pummel/test-net-tls.js
test/pummel/test-timers.js
test/pummel/test-watch-file.js
test/simple/test-buffer.js
test/simple/test-child-process-buffering.js
test/simple/test-child-process-custom-fds.js
test/simple/test-child-process-env.js
test/simple/test-child-process-ipc.js
test/simple/test-child-process-stdin.js
test/simple/test-child-process-stdout-flush.js
test/simple/test-crypto.js
test/simple/test-dgram-pingpong.js
test/simple/test-eio-race.js
test/simple/test-eio-race2.js
test/simple/test-eio-race4.js
test/simple/test-error-reporting.js
test/simple/test-event-emitter-add-listeners.js
test/simple/test-event-emitter-remove-listeners.js
test/simple/test-exception-handler.js
test/simple/test-exec.js
test/simple/test-executable-path.js
test/simple/test-file-read-noexist.js
test/simple/test-fs-chmod.js
test/simple/test-fs-read-buffer.js
test/simple/test-fs-read.js
test/simple/test-fs-readfile-empty.js
test/simple/test-fs-realpath.js
test/simple/test-fs-stat.js
test/simple/test-fs-symlink.js
test/simple/test-fs-write.js
test/simple/test-http-1.0.js
test/simple/test-http-304.js
test/simple/test-http-cat.js
test/simple/test-http-chunked.js
test/simple/test-http-client-upload.js
test/simple/test-http-exceptions.js
test/simple/test-http-full-response.js
test/simple/test-http-malformed-request.js
test/simple/test-http-parser.js
test/simple/test-http-set-timeout.js
test/simple/test-http-tls.js
test/simple/test-http-wget.js
test/simple/test-http-write-empty-string.js
test/simple/test-memory-usage.js
test/simple/test-mkdir-rmdir.js
test/simple/test-module-loading.js
test/simple/test-net-binary.js
test/simple/test-net-pingpong.js
test/simple/test-net-reconnect.js
test/simple/test-net-tls.js
test/simple/test-next-tick-ordering.js
test/simple/test-readdir.js
test/simple/test-regression-object-prototype.js
test/simple/test-signal-handler.js
test/simple/test-signal-unregister.js
test/simple/test-stdin-from-file.js
test/simple/test-stdout-to-file.js
test/simple/test-string-decoder.js
test/simple/test-utf8-scripts.js

index 627835b..1ab9097 100644 (file)
@@ -3,14 +3,14 @@ Buffer = require("buffer").Buffer;
 
 port = parseInt(process.env.PORT || 8000);
 
-var puts = require("sys").puts;
+var console.log = require("sys").console.log;
 
 var old = (process.argv[2] == 'old');
 
-puts('pid ' + process.pid);
+console.log('pid ' + process.pid);
 
 http = require(old ? "http_old" : 'http');
-if (old) puts('old version');
+if (old) console.log('old version');
 
 fixed = ""
 for (var i = 0; i < 20*1024; i++) {
@@ -32,7 +32,7 @@ http.createServer(function (req, res) {
     if (n <= 0)
       throw "bytes called with n <= 0" 
     if (stored[n] === undefined) {
-      puts("create stored[n]");
+      console.log("create stored[n]");
       stored[n] = "";
       for (var i = 0; i < n; i++) {
         stored[n] += "C"
@@ -44,7 +44,7 @@ http.createServer(function (req, res) {
     var n = parseInt(arg, 10)
     if (n <= 0) throw new Error("bytes called with n <= 0");
     if (storedBuffer[n] === undefined) {
-      puts("create storedBuffer[n]");
+      console.log("create storedBuffer[n]");
       storedBuffer[n] = new Buffer(n);
       for (var i = 0; i < n; i++) {
         storedBuffer[n][i] = "C".charCodeAt(0);
@@ -79,4 +79,4 @@ http.createServer(function (req, res) {
   }
 }).listen(port);
 
-puts('Listening at http://127.0.0.1:'+port+'/');
+console.log('Listening at http://127.0.0.1:'+port+'/');
index 7917c76..b1479b6 100644 (file)
@@ -22,9 +22,9 @@ function runNext (i) {
   sys.print(benchmarks[i] + ": ");
   exec(benchmarks[i], function (elapsed, code) {
     if (code != 0) {
-      sys.puts("ERROR  ");
+      console.log("ERROR  ");
     }
-    sys.puts(elapsed);
+    console.log(elapsed);
     runNext(i+1);
   });
 };
index b2b5d6c..15ef58c 100755 (executable)
@@ -1,9 +1,7 @@
 #!/usr/bin/env node
 
-var puts = require("sys").puts;
-
-puts("Type '.help' for options.");
-puts("(The REPL can also be started by typing 'node' without arguments)");
+console.log("Type '.help' for options.");
+console.log("(The REPL can also be started by typing 'node' without arguments)");
 
 require('repl').start();
 
index 19951e6..cfa90fb 100644 (file)
@@ -6,15 +6,14 @@ node(1) -- evented I/O for V8 JavaScript
 An example of a web server written with Node which responds with 'Hello
 World':
 
-    var sys = require('sys'),
-      http = require('http');
+    var http = require('http');
 
     http.createServer(function (request, response) {
       response.writeHead(200, {'Content-Type': 'text/plain'});
       response.end('Hello World\n');
     }).listen(8124);
 
-    sys.puts('Server running at http://127.0.0.1:8124/');
+    console.log('Server running at http://127.0.0.1:8124/');
 
 To run the server, put the code into a file called `example.js` and execute
 it with the node program
@@ -85,13 +84,12 @@ of `'utf8'` encoding, the method will not write partial characters.
 
 Example: write a utf8 string into a buffer, then print it
 
-    var sys = require('sys'),
-      Buffer = require('buffer').Buffer,
+    var Buffer = require('buffer').Buffer,
       buf = new Buffer(256),
       len;
 
     len = buf.write('\u00bd + \u00bc = \u00be', 'utf8', 0);
-    sys.puts(len + " bytes: " + buf.toString('utf8', 0, len));
+    console.log(len + " bytes: " + buf.toString('utf8', 0, len));
 
     // 12 bytes: ½ + ¼ = ¾
     
@@ -111,8 +109,7 @@ so the legal range is between `0x00` and `0xFF` hex or `0` and `255`.
 
 Example: copy an ASCII string into a buffer, one byte at a time:
 
-    var sys = require('sys'),
-      Buffer = require('buffer').Buffer,
+    var Buffer = require('buffer').Buffer,
       str = "node.js",
       buf = new Buffer(str.length),
       i;
@@ -121,7 +118,7 @@ Example: copy an ASCII string into a buffer, one byte at a time:
       buf[i] = str.charCodeAt(i);
     }
 
-    sys.puts(buf);
+    console.log(buf);
 
     // node.js
 
@@ -134,11 +131,10 @@ string.
 
 Example:
 
-    var sys = require('sys'),
-      Buffer = require('buffer').Buffer,
+    var Buffer = require('buffer').Buffer,
       str = '\u00bd + \u00bc = \u00be';
 
-    sys.puts(str + ": " + str.length + " characters, " + 
+    console.log(str + ": " + str.length + " characters, " +
       Buffer.byteLength(str, 'utf8') + " bytes");
 
     // ½ + ¼ = ¾: 9 characters, 12 bytes
@@ -150,13 +146,12 @@ The size of the buffer in bytes.  Note that this is not necessarily the size
 of the contents. `length` refers to the amount of memory allocated for the 
 buffer object.  It does not change when the contents of the buffer are changed.
 
-    var sys = require('sys'),
-      Buffer = require('buffer').Buffer,
+    var Buffer = require('buffer').Buffer,
       buf = new Buffer(1234);
 
-    sys.puts(buf.length);
+    console.log(buf.length);
     buf.write("some string", "ascii", 0);
-    sys.puts(buf.length);
+    console.log(buf.length);
 
     // 1234
     // 1234
@@ -168,8 +163,7 @@ Does a memcpy() between buffers.
 Example: build two Buffers, then copy `buf1` from byte 16 through byte 20
 into `buf2`, starting at the 8th byte in `buf2`.
 
-    var sys = require('sys'),
-      Buffer = require('buffer').Buffer,
+    var Buffer = require('buffer').Buffer,
       buf1 = new Buffer(26),
       buf2 = new Buffer(26),
       i;
@@ -180,7 +174,7 @@ into `buf2`, starting at the 8th byte in `buf2`.
     }
 
     buf1.copy(buf2, 8, 16, 20);
-    sys.puts(buf2.toString('ascii', 0, 25));
+    console.log(buf2.toString('ascii', 0, 25));
 
     // !!!!!!!!qrst!!!!!!!!!!!!!
     
@@ -196,8 +190,7 @@ indexes.
 Example: build a Buffer with the ASCII alphabet, take a slice, then modify one byte
 from the original Buffer.
 
-    var sys = require('sys'),
-      Buffer = require('buffer').Buffer,
+    var Buffer = require('buffer').Buffer,
       buf1 = new Buffer(26), buf2,
       i;
   
@@ -206,9 +199,9 @@ from the original Buffer.
     }
 
     buf2 = buf1.slice(0, 3);
-    sys.puts(buf2.toString('ascii', 0, buf2.length));
+    console.log(buf2.toString('ascii', 0, buf2.length));
     buf1[0] = 33;
-    sys.puts(buf2.toString('ascii', 0, buf2.length));
+    console.log(buf2.toString('ascii', 0, buf2.length));
 
     // abc
     // !bc
@@ -254,7 +247,7 @@ terminate execution and display the exception's stack trace.
 Adds a listener to the end of the listeners array for the specified event.
 
     server.addListener('stream', function (stream) {
-      sys.puts('someone connected!');
+      console.log('someone connected!');
     });
 
 
@@ -415,10 +408,8 @@ An array of search paths for `require()`.  This array can be modified to add cus
 
 Example: add a new path to the beginning of the search list
 
-    var sys = require('sys');
-
     require.paths.unshift('/usr/local/node');
-    sys.puts(require.paths);
+    console.log(require.paths);
     // /usr/local/node,/Users/mjr/.node_libraries
 
 
@@ -433,9 +424,8 @@ The dirname of the script being executed.
 
 Example: running `node example.js` from `/Users/mjr`
 
-    var sys = require('sys');
-    sys.puts(__filename);
-    sys.puts(__dirname);
+    console.log(__filename);
+    console.log(__dirname);
     // /Users/mjr/example.js
     // /Users/mjr
 
@@ -464,13 +454,11 @@ timers may not be scheduled.
 
 Example of listening for `exit`:
 
-    var sys = require('sys');
-
     process.addListener('exit', function () {
       process.nextTick(function () {
-       sys.puts('This will not run');
+       console.log('This will not run');
       });
-      sys.puts('About to exit.');
+      console.log('About to exit.');
     });
 
 ### Event: 'uncaughtException'
@@ -483,19 +471,17 @@ a stack trace and exit) will not occur.
 
 Example of listening for `uncaughtException`:
 
-    var sys = require('sys');
-
     process.addListener('uncaughtException', function (err) {
-      sys.puts('Caught exception: ' + err);
+      console.log('Caught exception: ' + err);
     });
 
     setTimeout(function () {
-      sys.puts('This will still run.');
+      console.log('This will still run.');
     }, 500);
 
     // Intentionally cause an exception, but don't catch it.
     nonexistentFunc();
-    sys.puts('This will not run.');
+    console.log('This will not run.');
 
 Note that `uncaughtException` is a very crude mechanism for exception
 handling.  Using try / catch in your program will give you more control over
@@ -512,11 +498,10 @@ standard POSIX signal names such as SIGINT, SIGUSR1, etc.
 
 Example of listening for `SIGINT`:
 
-    var sys = require('sys'),
-        stdin = process.openStdin();
+    var stdin = process.openStdin();
 
     process.addListener('SIGINT', function () {
-      sys.puts('Got SIGINT.  Press Control-D to exit.');
+      console.log('Got SIGINT.  Press Control-D to exit.');
     });
 
 An easy way to send the `SIGINT` signal is with `Control-C` in most terminal
@@ -527,9 +512,9 @@ programs.
 
 A writable stream to `stdout`.
 
-Example: the definition of `sys.puts`
+Example: the definition of `console.log`
 
-    exports.puts = function (d) {
+    console.log = function (d) {
       process.stdout.write(d + '\n');
     };
 
@@ -560,10 +545,8 @@ An array containing the command line arguments.  The first element will be
 next elements will be any additional command line arguments.
 
     // print process.argv
-    var sys = require('sys');
-
     process.argv.forEach(function (val, index, array) {
-      sys.puts(index + ': ' + val);
+      console.log(index + ': ' + val);
     });
 
 This will generate:
@@ -585,15 +568,13 @@ This is the absolute pathname of the executable that started the process.
 
 Changes the current working directory of the process or throws an exception if that fails.
 
-    var sys = require('sys');
-
-    sys.puts('Starting directory: ' + process.cwd());
+    console.log('Starting directory: ' + process.cwd());
     try {
       process.chdir('/tmp');
-      sys.puts('New directory: ' + process.cwd());
+      console.log('New directory: ' + process.cwd());
     }
     catch (err) {
-      sys.puts('chdir: ' + err);
+      console.log('chdir: ' + err);
     }
 
 
@@ -605,14 +586,13 @@ will be used as a filename if a stack trace is generated by the compiled code.
 
 Example of using `process.compile` and `eval` to run the same code:
 
-    var sys = require('sys'),
-        localVar = 123,
+    var localVar = 123,
         compiled, evaled;
 
     compiled = process.compile('localVar = 1;', 'myfile.js');
-    sys.puts('localVar: ' + localVar + ', compiled: ' + compiled);
+    console.log('localVar: ' + localVar + ', compiled: ' + compiled);
     evaled = eval('localVar = 1;');
-    sys.puts('localVar: ' + localVar + ', evaled: ' + evaled);
+    console.log('localVar: ' + localVar + ', evaled: ' + evaled);
 
     // localVar: 123, compiled: 1
     // localVar: 1, evaled: 1
@@ -629,7 +609,7 @@ See also: `Script`
 
 Returns the current working directory of the process.
 
-    require('sys').puts('Current directory: ' + process.cwd());
+    console.log('Current directory: ' + process.cwd());
 
 
 ### process.env
@@ -653,15 +633,13 @@ The shell that executed node should see the exit code as 1.
 
 Gets/sets the group identity of the process. (See setgid(2).)  This is the numerical group id, not the group name.
 
-    var sys = require('sys');
-
-    sys.puts('Current gid: ' + process.getgid());
+    console.log('Current gid: ' + process.getgid());
     try {
       process.setgid(501);
-      sys.puts('New gid: ' + process.getgid());
+      console.log('New gid: ' + process.getgid());
     }
     catch (err) {
-      sys.puts('Failed to set gid: ' + err);
+      console.log('Failed to set gid: ' + err);
     }
 
 
@@ -669,15 +647,13 @@ Gets/sets the group identity of the process. (See setgid(2).)  This is the numer
 
 Gets/sets the user identity of the process. (See setuid(2).)  This is the numerical userid, not the username.
 
-    var sys = require('sys');
-
-    sys.puts('Current uid: ' + process.getuid());
+    console.log('Current uid: ' + process.getuid());
     try {
       process.setuid(501);
-      sys.puts('New uid: ' + process.getuid());
+      console.log('New uid: ' + process.getuid());
     }
     catch (err) {
-      sys.puts('Failed to set uid: ' + err);
+      console.log('Failed to set uid: ' + err);
     }
 
 
@@ -685,13 +661,13 @@ Gets/sets the user identity of the process. (See setuid(2).)  This is the numeri
 
 A compiled-in property that exposes `NODE_VERSION`.
 
-    require('sys').puts('Version: ' + process.version);
+    console.log('Version: ' + process.version);
 
 ### process.installPrefix
 
 A compiled-in property that exposes `NODE_PREFIX`.
 
-    require('sys').puts('Prefix: ' + process.installPrefix);
+    console.log('Prefix: ' + process.installPrefix);
 
 
 ### process.kill(pid, signal)
@@ -707,14 +683,12 @@ may do something other than kill the target process.
 
 Example of sending a signal to yourself:
 
-    var sys = require('sys');
-
     process.addListener('SIGHUP', function () {
-      sys.puts('Got SIGHUP signal.');
+      console.log('Got SIGHUP signal.');
     });
 
     setTimeout(function () {
-      sys.puts('Exiting.');
+      console.log('Exiting.');
       process.exit(0);
     }, 100);
 
@@ -725,14 +699,14 @@ Example of sending a signal to yourself:
 
 The PID of the process.
 
-    require('sys').puts('This process is pid ' + process.pid);
+    console.log('This process is pid ' + process.pid);
 
 
 ### process.platform
 
 What platform you're running on. `'linux2'`, `'darwin'`, etc.
 
-    require('sys').puts('This platform is ' + process.platform);
+    console.log('This platform is ' + process.platform);
 
 
 ### process.memoryUsage()
@@ -741,7 +715,7 @@ Returns an object describing the memory usage of the Node process.
 
     var sys = require('sys');
 
-    sys.puts(sys.inspect(process.memoryUsage()));
+    console.log(sys.inspect(process.memoryUsage()));
 
 This will generate:
 
@@ -760,10 +734,8 @@ On the next loop around the event loop call this callback.
 This is *not* a simple alias to `setTimeout(fn, 0)`, it's much more
 efficient.
 
-    var sys = require('sys');
-
     process.nextTick(function () {
-      sys.puts('nextTick callback');
+      console.log('nextTick callback');
     });
 
 
@@ -773,12 +745,11 @@ Sets or read the process's file mode creation mask. Child processes inherit
 the mask from the parent process. Returns the old mask if `mask` argument is
 given, otherwise returns the current mask.
 
-    var sys = require('sys'),
-        oldmask, newmask = 0644;
+    var oldmask, newmask = 0644;
 
     oldmask = process.umask(newmask);
-    sys.puts('Changed umask from: ' + oldmask.toString(8) +
-             ' to ' + newmask.toString(8));
+    console.log('Changed umask from: ' + oldmask.toString(8) +
+                ' to ' + newmask.toString(8));
 
 
 
@@ -788,16 +759,9 @@ These functions are in the module `'sys'`. Use `require('sys')` to access
 them.
 
 
-### sys.puts(string)
-
-Outputs `string` and a trailing newline to `stdout`.
-
-    require('sys').puts('String with a newline');
-
-
 ### sys.print(string)
 
-Like `puts()` but without the trailing newline.
+Like `console.log()` but without the trailing newline.
 
     require('sys').print('String with no newline');
 
@@ -834,7 +798,7 @@ Example of inspecting all properties of the `sys` object:
 
     var sys = require('sys');
 
-    sys.puts(sys.inspect(sys, true, null));
+    console.log(sys.inspect(sys, true, null));
 
 
 ### sys.pump(readableStream, writeableStream, [callback])
@@ -920,19 +884,18 @@ Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the exit cod
     });
 
     ls.addListener('exit', function (code) {
-      sys.puts('child process exited with code ' + code);
+      console.log('child process exited with code ' + code);
     });
 
 
 Example of checking for failed exec:
 
-    var sys   = require('sys'),
-        spawn = require('child_process').spawn,
+    var spawn = require('child_process').spawn,
         child = spawn('bad_command');
 
     child.stderr.addListener('data', function (data) {
       if (/^execvp\(\)/.test(data.asciiSlice(0,data.length))) {
-        sys.puts('Failed to start child process.');
+        console.log('Failed to start child process.');
       }
     });
 
@@ -945,12 +908,11 @@ See also: `child_process.exec()`
 Send a signal to the child process. If no argument is given, the process will
 be sent `'SIGTERM'`. See `signal(7)` for a list of available signals.
 
-    var sys   = require('sys'),
-        spawn = require('child_process').spawn,
+    var spawn = require('child_process').spawn,
         grep  = spawn('grep', ['ssh']);
 
     grep.addListener('exit', function (code, signal) {
-      sys.puts('child process terminated due to receipt of signal '+signal);
+      console.log('child process terminated due to receipt of signal '+signal);
     });
 
     // send SIGHUP to process
@@ -968,11 +930,10 @@ The PID of the child process.
 
 Example:
 
-    var sys   = require('sys'),
-        spawn = require('child_process').spawn,
+    var spawn = require('child_process').spawn,
         grep  = spawn('grep', ['ssh']);
 
-    sys.puts('Spawned child pid: ' + grep.pid);
+    console.log('Spawned child pid: ' + grep.pid);
     grep.stdin.end();
 
 
@@ -999,7 +960,7 @@ Example: A very elaborate way to run 'ps ax | grep ssh'
 
     ps.addListener('exit', function (code) {
       if (code !== 0) {
-        sys.puts('ps process exited with code ' + code);
+        console.log('ps process exited with code ' + code);
       }
       grep.stdin.end();
     });
@@ -1014,7 +975,7 @@ Example: A very elaborate way to run 'ps ax | grep ssh'
 
     grep.addListener('exit', function (code) {
       if (code !== 0) {
-        sys.puts('grep process exited with code ' + code);
+        console.log('grep process exited with code ' + code);
       }
     });
 
@@ -1025,12 +986,11 @@ Closes the child process's `stdin` stream.  This often causes the child process
 
 Example:
 
-    var sys   = require('sys'),
-        spawn = require('child_process').spawn,
+    var spawn = require('child_process').spawn,
         grep  = spawn('grep', ['ssh']);
 
     grep.addListener('exit', function (code) {
-      sys.puts('child process exited with code ' + code);
+      console.log('child process exited with code ' + code);
     });
 
     grep.stdin.end();
@@ -1050,7 +1010,7 @@ output, and return it all in a callback.
         sys.print('stdout: ' + stdout);
         sys.print('stderr: ' + stderr);
         if (error !== null) {
-          sys.puts('exec error: ' + error);
+          console.log('exec error: ' + error);
         }
       });
 
@@ -1091,17 +1051,16 @@ runs it and returns the result. Running code does not have access to local scope
 
 Example of using `Script.runInThisContext` and `eval` to run the same code:
 
-    var sys = require('sys'),
-        localVar = 123,
+    var localVar = 123,
         usingscript, evaled,
         Script = process.binding('evals').Script;
 
     usingscript = Script.runInThisContext('localVar = 1;',
       'myfile.js');
-    sys.puts('localVar: ' + localVar + ', usingscript: ' +
+    console.log('localVar: ' + localVar + ', usingscript: ' +
       usingscript);
     evaled = eval('localVar = 1;');
-    sys.puts('localVar: ' + localVar + ', evaled: ' +
+    console.log('localVar: ' + localVar + ', evaled: ' +
       evaled);
 
     // localVar: 123, usingscript: 1
@@ -1133,7 +1092,7 @@ These globals are contained in the sandbox.
 
     Script.runInNewContext(
       'count += 1; name = "kitty"', sandbox, 'myfile.js');
-    sys.puts(sys.inspect(sandbox));
+    console.log(sys.inspect(sandbox));
 
     // { animal: 'cat', count: 3, name: 'kitty' }
 
@@ -1166,8 +1125,7 @@ Running code does not have access to local scope, but does have access to the `g
 
 Example of using `script.runInThisContext` to compile code once and run it multiple times:
 
-    var sys = require('sys'),
-        Script = process.binding('evals').Script,
+    var Script = process.binding('evals').Script,
         scriptObj, i;
     
     globalVar = 0;
@@ -1178,7 +1136,7 @@ Example of using `script.runInThisContext` to compile code once and run it multi
       scriptObj.runInThisContext();
     }
 
-    sys.puts(globalVar);
+    console.log(globalVar);
 
     // 1000
 
@@ -1207,7 +1165,7 @@ These globals are contained in the sandbox.
       scriptObj.runInNewContext(sandbox);
     }
 
-    sys.puts(sys.inspect(sandbox));
+    console.log(sys.inspect(sandbox));
 
     // { animal: 'cat', count: 12, name: 'kitty' }
 
@@ -1229,32 +1187,30 @@ completed successfully, then the first argument will be `null` or `undefined`.
 
 Here is an example of the asynchronous version:
 
-    var fs = require('fs'),
-        sys = require('sys');
+    var fs = require('fs');
 
     fs.unlink('/tmp/hello', function (err) {
       if (err) throw err;
-      sys.puts('successfully deleted /tmp/hello');
+      console.log('successfully deleted /tmp/hello');
     });
 
 Here is the synchronous version:
 
-    var fs = require('fs'),
-        sys = require('sys');
+    var fs = require('fs');
 
     fs.unlinkSync('/tmp/hello')
-    sys.puts('successfully deleted /tmp/hello');
+    console.log('successfully deleted /tmp/hello');
 
 With the asynchronous methods there is no guaranteed ordering. So the
 following is prone to error:
 
     fs.rename('/tmp/hello', '/tmp/world', function (err) {
       if (err) throw err;
-      sys.puts('renamed complete');
+      console.log('renamed complete');
     });
     fs.stat('/tmp/world', function (err, stats) {
       if (err) throw err;
-      sys.puts('stats: ' + JSON.stringify(stats));
+      console.log('stats: ' + JSON.stringify(stats));
     });
 
 It could be that `fs.stat` is executed before `fs.rename`.
@@ -1264,7 +1220,7 @@ The correct way to do this is to chain the callbacks.
       if (err) throw err;
       fs.stat('/tmp/world', function (err, stats) {
         if (err) throw err;
-        sys.puts('stats: ' + JSON.stringify(stats));
+        console.log('stats: ' + JSON.stringify(stats));
       });
     });
 
@@ -1448,7 +1404,7 @@ Asynchronously reads the entire contents of a file. Example:
 
     fs.readFile('/etc/passwd', function (err, data) {
       if (err) throw err;
-      sys.puts(data);
+      console.log(data);
     });
 
 The callback is passed two arguments `(err, data)`, where `data` is the
@@ -1471,7 +1427,7 @@ Asynchronously writes data to a file. Example:
 
     fs.writeFile('message.txt', 'Hello Node', function (err) {
       if (err) throw err;
-      sys.puts('It\'s saved!');
+      console.log('It\'s saved!');
     });
 
 ### fs.writeFileSync(filename, data, encoding='utf8')
@@ -1491,8 +1447,8 @@ The `listener` gets two arguments the current stat object and the previous
 stat object:
 
     fs.watchFile(f, function (curr, prev) {
-      sys.puts('the current mtime is: ' + curr.mtime);
-      sys.puts('the previous mtime was: ' + prev.mtime);
+      console.log('the current mtime is: ' + curr.mtime);
+      console.log('the previous mtime was: ' + prev.mtime);
     });
 
 These stat objects are instances of `fs.Stat`. 
@@ -1874,18 +1830,17 @@ stream. _Currently the implementation does not pipeline requests._
 
 Example of connecting to `google.com`:
 
-    var sys = require('sys'),
-       http = require('http');
+    var http = require('http');
     var google = http.createClient(80, 'www.google.com');
     var request = google.request('GET', '/',
       {'host': 'www.google.com'});
     request.end();
     request.addListener('response', function (response) {
-      sys.puts('STATUS: ' + response.statusCode);
-      sys.puts('HEADERS: ' + JSON.stringify(response.headers));
+      console.log('STATUS: ' + response.statusCode);
+      console.log('HEADERS: ' + JSON.stringify(response.headers));
       response.setEncoding('utf8');
       response.addListener('data', function (chunk) {
-        sys.puts('BODY: ' + chunk);
+        console.log('BODY: ' + chunk);
       });
     });
 
@@ -1950,7 +1905,7 @@ event, the entire body will be caught.
     // Good
     request.addListener('response', function (response) {
       response.addListener('data', function (chunk) {
-        sys.puts('BODY: ' + chunk);
+        console.log('BODY: ' + chunk);
       });
     });
 
@@ -1958,7 +1913,7 @@ event, the entire body will be caught.
     request.addListener('response', function (response) {
       setTimeout(function () {
         response.addListener('data', function (chunk) {
-          sys.puts('BODY: ' + chunk);
+          console.log('BODY: ' + chunk);
         });
       }, 10);
     });
@@ -2433,22 +2388,21 @@ Use `require('dns')` to access this module.
 Here is an example which resolves `'www.google.com'` then reverse
 resolves the IP addresses which are returned.
 
-    var dns = require('dns'),
-        sys = require('sys');
+    var dns = require('dns');
 
     dns.resolve4('www.google.com', function (err, addresses) {
       if (err) throw err;
 
-      sys.puts('addresses: ' + JSON.stringify(addresses));
+      console.log('addresses: ' + JSON.stringify(addresses));
 
       for (var i = 0; i < addresses.length; i++) {
         var a = addresses[i];
         dns.reverse(a, function (err, domains) {
           if (err) {
-            sys.puts('reverse for ' + a + ' failed: ' + 
+            console.log('reverse for ' + a + ' failed: ' +
               err.message);
           } else {
-            sys.puts('reverse for ' + a + ': ' + 
+            console.log('reverse for ' + a + ': ' +
               JSON.stringify(domains));
           }
         });
@@ -2789,7 +2743,7 @@ dropped into the REPL. It has simplistic emacs line-editting.
     node> a = [ 1, 2, 3];
     [ 1, 2, 3 ]
     node> a.forEach(function (v) {
-    ...   sys.puts(v);
+    ...   console.log(v);
     ...   });
     1
     2
@@ -2814,8 +2768,7 @@ will share the same global object but will have unique I/O.
 
 Here is an example that starts a REPL on stdin, a Unix socket, and a TCP socket:
 
-    var sys = require("sys"),
-        net = require("net"),
+    var net = require("net"),
         repl = require("repl");
 
     connections = 0;
@@ -2892,10 +2845,9 @@ one-to-one correspondence.  As an example, `foo.js` loads the module
 
 The contents of `foo.js`:
 
-    var circle = require('./circle'),
-        sys = require('sys');
-    sys.puts( 'The area of a circle of radius 4 is '
-      + circle.area(4));
+    var circle = require('./circle');
+    console.log( 'The area of a circle of radius 4 is '
+               + circle.area(4));
 
 The contents of `circle.js`:
 
index 930c00c..ab9821e 100644 (file)
       </p>
 
       <pre>
-var sys = require('sys'),
-   http = require('http');
+var http = require('http');
 http.createServer(function (req, res) {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello World\n');
 }).listen(8124, "127.0.0.1");
-sys.puts('Server running at http://127.0.0.1:8124/');
+console.log('Server running at http://127.0.0.1:8124/');
 </pre>
 
       <p>
index 2b7b00b..ae098fd 100644 (file)
@@ -187,6 +187,13 @@ process.openStdin = function () {
 };
 
 
+global.console = {};
+
+global.console.log = function (x) {
+  process.stdout.write(x + '\n');
+};
+
+
 process.exit = function (code) {
   process.emit("exit");
   process.reallyExit(code);
@@ -209,7 +216,7 @@ if (process.argv[1]) {
 } else {
   // No arguments, run the repl
   var repl = module.requireNative('repl');
-  process.stdout.write("Type '.help' for options.\n");
+  console.log("Type '.help' for options.");
   repl.start();
 }
 
index 19edc29..4f12327 100644 (file)
@@ -1,11 +1,11 @@
 require("../common.js");
 http = require("/http.js");
 
-puts("hello world");
+console.log("hello world");
 
 var body = "exports.A = function() { return 'A';}";
 var server = http.createServer(function (req, res) {
-    puts("req?");
+    console.log("req?");
   res.sendHeader(200, {
     "Content-Length": body.length,
     "Content-Type": "text/plain"
index f92757a..631eb65 100644 (file)
@@ -126,7 +126,7 @@ function cmpResults(expected, result, ttl, cname) {
     if (expected.length == 1 && expected[0] == '3(NXDOMAIN)' && result.length == 0) {
       // it's ok, dig returns NXDOMAIN, while dns module returns nothing
     } else {
-      puts('---WARNING---\nexpected ' + expected + '\nresult ' + result + '\n-------------');
+      console.log('---WARNING---\nexpected ' + expected + '\nresult ' + result + '\n-------------');
     }
     return;
   }
@@ -136,6 +136,6 @@ function cmpResults(expected, result, ttl, cname) {
   ll = expected.length;
   while (ll--) {
     assert.equal(result[ll], expected[ll]);
-    puts("Result " + result[ll] + " was equal to expected " + expected[ll]);
+    console.log("Result " + result[ll] + " was equal to expected " + expected[ll]);
   }
 }
index 8c70375..9f9f245 100644 (file)
@@ -3,16 +3,16 @@
 require("../common");
 
 
-puts('first stat ...');
+console.log('first stat ...');
 
 fs.stat(__filename)
   .addCallback( function(stats) {
-    puts('second stat ...');
+    console.log('second stat ...');
     fs.stat(__filename)
       .timeout(1000)
       .wait();
 
-    puts('test passed');
+    console.log('test passed');
   })
   .addErrback(function() {
     throw new Exception();
index 9ddb966..f3925d3 100644 (file)
@@ -30,7 +30,7 @@ var proxy = http.createServer(function (req, res) {
 
 
   c.addListener('error', function (e) {
-    puts('proxy client error. sent ' + sent);
+    console.log('proxy client error. sent ' + sent);
     throw e;
   });
 
@@ -86,7 +86,7 @@ function call_chargen(list) {
     req.end();
 
   } else {
-    sys.puts("End of list. closing servers");
+    console.log("End of list. closing servers");
     proxy.close();
     chargen.close();
     done = true;
index 671e3ae..5956df3 100644 (file)
@@ -10,7 +10,7 @@ server = http.createServer(function (req, res) {
   res.writeHeader(200 , { 'Content-Length': body.length.toString()
                         , 'Content-Type': 'text/plain'
                         });
-  sys.puts('method: ' + req.method);
+  console.log('method: ' + req.method);
   if (req.method != 'HEAD') res.write(body);
   res.end();
 });
@@ -22,7 +22,7 @@ server.addListener('listening', function() {
   var client = http.createClient(PORT);
   var request = client.request("HEAD", "/");
   request.addListener('response', function (response) {
-    sys.puts('got response');
+    console.log('got response');
     response.addListener("data", function () {
       process.exit(2);
     });
index 19a2baf..5d0eda3 100644 (file)
@@ -27,7 +27,7 @@ server.addListener('listening', function () {
        requests_ok++;
      }
      if (requests_complete == request_count) {
-       puts("\nrequests ok: " + requests_ok);
+       console.log("\nrequests ok: " + requests_ok);
        server.close();
      }
    });
index 00a0974..b098c3e 100644 (file)
@@ -27,7 +27,7 @@ var cmd = 'NODE_PATH='+libDir+' '+nodeBinary+' http://localhost:'+PORT+'/moduleB
 
 sys.exec(cmd, function (err, stdout, stderr) {
   if (err) throw err;
-  puts('success!');
+  console.log('success!');
   modulesLoaded++;
   server.close();
 });
index eba7a88..909ec7d 100644 (file)
@@ -15,14 +15,14 @@ var credentials = crypto.createCredentials({ca:caPem});
 
 client.setEncoding("UTF8");
 client.addListener("connect", function () {
-  sys.puts("client connected.");
+  console.log("client connected.");
   client.setSecure(credentials);
 });
 
 client.addListener("secure", function () {
-  sys.puts("client secure : "+JSON.stringify(client.getCipher()));
-  sys.puts(JSON.stringify(client.getPeerCertificate()));
-  sys.puts("verifyPeer : "+client.verifyPeer());
+  console.log("client secure : "+JSON.stringify(client.getCipher()));
+  console.log(JSON.stringify(client.getPeerCertificate()));
+  console.log("verifyPeer : "+client.verifyPeer());
   client.write("GET / HTTP/1.0\r\n\r\n");
 });
 
@@ -31,6 +31,6 @@ client.addListener("data", function (chunk) {
 });
 
 client.addListener("end", function () {
-  sys.puts("client disconnected.");
+  console.log("client disconnected.");
 });
 
index f89ee4b..5aef382 100644 (file)
@@ -15,11 +15,11 @@ var server = net.createServer(function (connection) {
   connection.setEncoding("binary");
 
   connection.addListener("secure", function () {
-    //sys.puts("Secure");
+    //console.log("Secure");
   });
 
   connection.addListener("data", function (chunk) {
-    sys.puts("recved: " + JSON.stringify(chunk));
+    console.log("recved: " + JSON.stringify(chunk));
     connection.write("HTTP/1.0 200 OK\r\nContent-type: text/plain\r\nContent-length: 9\r\n\r\nOK : "+i+"\r\n\r\n");
     i=i+1;
     connection.end();
index 6aaf186..ee7cd47 100644 (file)
@@ -24,5 +24,5 @@ exports.D = function () {
 
 process.addListener("exit", function () {
   string = "C done";
-  puts("b/c.js exit");
+  console.log("b/c.js exit");
 });
index ba7a149..a777b6e 100644 (file)
@@ -3,7 +3,7 @@ var exec = require('child_process').exec,
 
 [0, 1].forEach(function(i) {
  exec('ls', function(err, stdout, stderr) {
-   puts(i);
+   console.log(i);
    throw new Error('hello world');
  });
 });
index 3763a11..268a613 100644 (file)
@@ -3,4 +3,4 @@ var root = require("./../root");
 
 exports.hello = function () {
   return root.calledFromFoo();
-};
\ No newline at end of file
+};
index b515639..d93488c 100644 (file)
@@ -7,4 +7,4 @@ exports.sayHello = function () {
 };
 exports.calledFromFoo = function () {
   return exports.hello;
-};
\ No newline at end of file
+};
index 6f85c5d..c6c8b82 100644 (file)
@@ -1 +1 @@
-process.exit(process.argv[2] || 1);
\ No newline at end of file
+process.exit(process.argv[2] || 1);
index fc6b8b5..c8e16d0 100644 (file)
@@ -1,4 +1,4 @@
 puts = require('sys').puts;
 for (var i = 0; i < 10; i++) {
-  puts('count ' + i);
+  console.log('count ' + i);
 }
index f2c1aac..9418698 100644 (file)
@@ -1,7 +1,7 @@
 require('../common');
 
 sys = require('sys');
-sys.puts([
+console.log([
  '_______________________________________________50',
  '______________________________________________100',
  '______________________________________________150',
index 2810b74..55b231e 100644 (file)
@@ -1,3 +1,3 @@
 require('../common');
 
-puts('hello world');
+console.log('hello world');
index fffe056..12c3ab5 100644 (file)
@@ -7,8 +7,8 @@ script.runInNewContext();
 ReferenceError: foo is not defined
     at evalmachine.<anonymous>:1:1
     at Object.<anonymous> (*test/message/undefined_reference_in_new_context.js:9:8)
-    at Module._compile (module:384:23)
-    at Module._loadScriptSync (module:393:8)
-    at Module.loadSync (module:296:10)
-    at Object.runMain (module:447:22)
-    at node.js:208:10
+    at Module._compile (module:*:23)
+    at Module._loadScriptSync (module:*:8)
+    at Module.loadSync (module:*:*)
+    at Object.runMain (module:*:*)
+    at node.js:*:*
index 76e4236..fb426ac 100644 (file)
@@ -16,7 +16,7 @@ function doSpawn (i) {
   });
 
   child.stderr.addListener("data", function (chunk) {
-    puts('stderr: ' + chunk);
+    console.log('stderr: ' + chunk);
   });
 
   child.addListener("exit", function () {
index a36a73f..4e74efd 100644 (file)
@@ -15,19 +15,19 @@ server.listen(PORT);
 var client = http.createClient(PORT);
 
 client.addListener("error", function() {
-  sys.puts("ERROR!");
+  console.log("ERROR!");
   errorCount++;
 });
 
 client.addListener("end", function() {
-  sys.puts("EOF!");
+  console.log("EOF!");
   eofCount++;
 });
 
 var request = client.request("GET", "/", {"host": "localhost"});
 request.end();
 request.addListener('response', function(response) {
-  sys.puts("STATUS: " + response.statusCode);
+  console.log("STATUS: " + response.statusCode);
 });
 
 setTimeout(function () {
index 235843a..4286783 100644 (file)
@@ -21,7 +21,7 @@ function runAb(opts, callback) {
   var command = "ab " + opts + " http://127.0.0.1:" + PORT + "/";
   exec(command, function (err, stdout, stderr) {
     if (err) {
-      puts("ab not installed? skipping test.\n" + stderr);
+      console.log("ab not installed? skipping test.\n" + stderr);
       process.exit();
       return;
     }
@@ -45,12 +45,12 @@ server.listen(PORT, function () {
   runAb("-k -c 100 -t 2", function (reqSec, keepAliveRequests) {
     keepAliveReqSec = reqSec;
     assert.equal(true, keepAliveRequests > 0);
-    puts("keep-alive: " + keepAliveReqSec + " req/sec");
+    console.log("keep-alive: " + keepAliveReqSec + " req/sec");
 
     runAb("-c 100 -t 2", function (reqSec, keepAliveRequests) {
       normalReqSec = reqSec;
       assert.equal(0, keepAliveRequests);
-      puts("normal: " + normalReqSec + " req/sec");
+      console.log("normal: " + normalReqSec + " req/sec");
       server.close();
     });
   });
index 9cff30b..fe026b9 100644 (file)
@@ -44,7 +44,7 @@ function runClient (callback) {
   });
 
   client.addListener("error", function (e) {
-    puts("\n\nERROOOOOr");
+    console.log("\n\nERROOOOOr");
     throw e;
   });
 
@@ -54,7 +54,7 @@ function runClient (callback) {
     assert.equal(bytes, client.recved.length);
 
     if (client.fd) {
-      puts(client.fd);
+      console.log(client.fd);
     }
     assert.ok(!client.fd);
 
@@ -77,5 +77,5 @@ server.listen(PORT, function () {
 
 process.addListener("exit", function () {
   assert.equal(connections_per_client * concurrency, total_connections);
-  puts("\nokay!");
+  console.log("\nokay!");
 });
index de84c0e..0dbf65a 100644 (file)
@@ -30,21 +30,21 @@ client.addListener("data", function (d) {
 
 setTimeout(function () {
   chars_recved = recv.length;
-  puts("pause at: " + chars_recved);
+  console.log("pause at: " + chars_recved);
   assert.equal(true, chars_recved > 1);
   client.pause();
   setTimeout(function () {
-    puts("resume at: " + chars_recved);
+    console.log("resume at: " + chars_recved);
     assert.equal(chars_recved, recv.length);
     client.resume();
 
     setTimeout(function () {
       chars_recved = recv.length;
-      puts("pause at: " + chars_recved);
+      console.log("pause at: " + chars_recved);
       client.pause();
 
       setTimeout(function () {
-        puts("resume at: " + chars_recved);
+        console.log("resume at: " + chars_recved);
         assert.equal(chars_recved, recv.length);
         client.resume();
 
index 5854674..6f18865 100644 (file)
@@ -14,7 +14,7 @@ function pingPongTest (port, host, on_complete) {
     socket.setEncoding("utf8");
 
     socket.addListener("data", function (data) {
-      puts(data);
+      console.log(data);
       assert.equal("PING", data);
       assert.equal("open", socket.readyState);
       assert.equal(true, count <= N);
@@ -30,13 +30,13 @@ function pingPongTest (port, host, on_complete) {
     });
 
     socket.addListener("end", function () {
-      puts("server-side socket EOF");
+      console.log("server-side socket EOF");
       assert.equal("writeOnly", socket.readyState);
       socket.end();
     });
 
     socket.addListener("close", function (had_error) {
-      puts("server-side socket.end");
+      console.log("server-side socket.end");
       assert.equal(false, had_error);
       assert.equal("closed", socket.readyState);
       socket.server.close();
@@ -54,7 +54,7 @@ function pingPongTest (port, host, on_complete) {
   });
 
   client.addListener("data", function (data) {
-    puts(data);
+    console.log(data);
     assert.equal("PONG", data);
     assert.equal("open", client.readyState);
 
@@ -63,7 +63,7 @@ function pingPongTest (port, host, on_complete) {
       if (count++ < N) {
         client.write("PING");
       } else {
-        puts("closing client");
+        console.log("closing client");
         client.end();
         client_ended = true;
       }
@@ -76,7 +76,7 @@ function pingPongTest (port, host, on_complete) {
   });
 
   client.addListener("close", function () {
-    puts("client.end");
+    console.log("client.end");
     assert.equal(N+1, count);
     assert.ok(client_ended);
     if (on_complete) on_complete();
index d96e398..a57234a 100644 (file)
@@ -14,7 +14,7 @@ function pingPongTest (port, host, on_complete) {
     if (host === "127.0.0.1" || host === "localhost" || !host) {
       assert.equal(socket.remoteAddress, "127.0.0.1");
     } else {
-      puts('host = ' + host + ', remoteAddress = ' + socket.remoteAddress);
+      console.log('host = ' + host + ', remoteAddress = ' + socket.remoteAddress);
       assert.equal(socket.remoteAddress, "::1");
     }
 
@@ -23,7 +23,7 @@ function pingPongTest (port, host, on_complete) {
     socket.timeout = 0;
 
     socket.addListener("data", function (data) {
-      puts("server got: " + JSON.stringify(data));
+      console.log("server got: " + JSON.stringify(data));
       assert.equal("open", socket.readyState);
       assert.equal(true, count <= N);
       if (/PING/.exec(data)) {
@@ -54,7 +54,7 @@ function pingPongTest (port, host, on_complete) {
   });
 
   client.addListener("data", function (data) {
-    puts('client got: ' + data);
+    console.log('client got: ' + data);
 
     assert.equal("PONG", data);
     count += 1;
index 8da7239..7205317 100644 (file)
@@ -2,13 +2,13 @@ require("../common");
 net = require("net");
 N = 160*1024; // 30kb
 
-puts("build big string");
+console.log("build big string");
 var body = "";
 for (var i = 0; i < N; i++) {
   body += "C";
 }
 
-puts("start server on port " + PORT);
+console.log("start server on port " + PORT);
 
 server = net.createServer(function (connection) {
   connection.addListener("connect", function () {
@@ -28,17 +28,17 @@ client = net.createConnection(PORT);
 client.setEncoding("ascii");
 client.addListener("data", function (d) {
   chars_recved += d.length;
-  puts("got " + chars_recved);
+  console.log("got " + chars_recved);
   if (!paused) {
     client.pause();
     npauses += 1;
     paused = true;
-    puts("pause");
+    console.log("pause");
     x = chars_recved;
     setTimeout(function () {
       assert.equal(chars_recved, x);
       client.resume();
-      puts("resume");
+      console.log("resume");
       paused = false;
     }, 100);
   }
index 6e4600d..e1938ab 100644 (file)
@@ -9,7 +9,7 @@ var echo_server = net.createServer(function (socket) {
   socket.setTimeout(timeout);
 
   socket.addListener("timeout", function () {
-    puts("server timeout");
+    console.log("server timeout");
     timeouttime = new Date;
     p(timeouttime);
     socket.destroy();
@@ -20,7 +20,7 @@ var echo_server = net.createServer(function (socket) {
   })
 
   socket.addListener("data", function (d) {
-    puts(d);
+    console.log(d);
     socket.write(d);
   });
 
@@ -30,14 +30,14 @@ var echo_server = net.createServer(function (socket) {
 });
 
 echo_server.listen(PORT, function () {
-  puts("server listening at " + PORT);
+  console.log("server listening at " + PORT);
 });
 
 var client = net.createConnection(PORT);
 client.setEncoding("UTF8");
 client.setTimeout(0); // disable the timeout for client
 client.addListener("connect", function () {
-  puts("client connected.");
+  console.log("client connected.");
   client.write("hello\r\n");
 });
 
@@ -45,12 +45,12 @@ client.addListener("data", function (chunk) {
   assert.equal("hello\r\n", chunk);
   if (exchanges++ < 5) {
     setTimeout(function () {
-      puts("client write 'hello'");
+      console.log("client write 'hello'");
       client.write("hello\r\n");
     }, 500);
 
     if (exchanges == 5) {
-      puts("wait for timeout - should come in " + timeout + " ms");
+      console.log("wait for timeout - should come in " + timeout + " ms");
       starttime = new Date;
       p(starttime);
     }
@@ -62,12 +62,12 @@ client.addListener("timeout", function () {
 });
 
 client.addListener("end", function () {
-  puts("client end");
+  console.log("client end");
   client.end();
 });
 
 client.addListener("close", function () {
-  puts("client disconnect");
+  console.log("client disconnect");
   echo_server.close();
 });
 
@@ -76,7 +76,7 @@ process.addListener("exit", function () {
   assert.ok(timeouttime != null);
 
   diff = timeouttime - starttime;
-  puts("diff = " + diff);
+  console.log("diff = " + diff);
 
   assert.ok(timeout < diff);
 
index d156b93..6d6dc31 100644 (file)
@@ -27,7 +27,7 @@ function tlsTest (port, host, caPem, keyPem, certPem) {
       assert.equal(verified, 1);
       assert.equal(peerDN, "C=UK,ST=Acknack Ltd,L=Rhys Jones,O=node.js,"
                            + "OU=Test TLS Certificate,CN=localhost");
-      puts("server got: " + JSON.stringify(data));
+      console.log("server got: " + JSON.stringify(data));
       assert.equal("open", socket.readyState);
       assert.equal(true, count <= N);
       if (/PING/.exec(data)) {
@@ -69,7 +69,7 @@ function tlsTest (port, host, caPem, keyPem, certPem) {
     assert.equal("PONG", data);
     count += 1;
 
-    puts("client got PONG");
+    console.log("client got PONG");
 
     if (sent_final_ping) {
       assert.equal("readOnly", client.readyState);
@@ -117,6 +117,6 @@ if (have_tls) {
     assert.equal(2, tests_run);
   });
 } else {
-  puts("Not compiled with TLS support -- skipping test");
+  console.log("Not compiled with TLS support -- skipping test");
   process.exit(0);
 }
index ce371fa..0aa470c 100644 (file)
@@ -12,7 +12,7 @@ setTimeout(function () {
 
   var diff = endtime - starttime;
   assert.ok(diff > 0);
-  puts("diff: " + diff);
+  console.log("diff: " + diff);
 
   assert.equal(true, 1000 - WINDOW < diff && diff < 1000 + WINDOW);
   setTimeout_called = true;
@@ -28,7 +28,7 @@ setInterval(function () {
 
   var diff = endtime - starttime;
   assert.ok(diff > 0);
-  puts("diff: " + diff);
+  console.log("diff: " + diff);
 
   var t = interval_count * 1000;
 
index 3f50714..492177b 100644 (file)
@@ -6,12 +6,12 @@ var path = require("path");
 var f = path.join(fixturesDir, "x.txt");
 var f2 = path.join(fixturesDir, "x2.txt");
 
-puts("watching for changes of " + f);
+console.log("watching for changes of " + f);
 
 var changes = 0;
 function watchFile () {
   fs.watchFile(f, function (curr, prev) {
-    puts(f + " change");
+    console.log(f + " change");
     changes++;
     assert.ok(curr.mtime != prev.mtime);
     fs.unwatchFile(f);
index 89a0148..949b5b8 100644 (file)
@@ -5,7 +5,7 @@ var Buffer = require('buffer').Buffer;
 
 var b = new Buffer(1024);
 
-puts("b.length == " + b.length);
+console.log("b.length == " + b.length);
 assert.equal(1024, b.length);
 
 for (var i = 0; i < 1024; i++) {
@@ -90,7 +90,7 @@ assert.deepEqual([0xDEADBEEF], b.unpack('N', 4));
 var testValue = '\u00F6\u65E5\u672C\u8A9E'; // ö日本語
 var buffer = new Buffer(32);
 var size = buffer.utf8Write(testValue, 0);
-puts('bytes written to buffer: ' + size);
+console.log('bytes written to buffer: ' + size);
 var slice = buffer.toString('utf8', 0, size);
 assert.equal(slice, testValue);
 
@@ -118,4 +118,4 @@ var e = new Buffer('über');
 assert.deepEqual(e, new Buffer([195, 188, 98, 101, 114]));
 
 var f = new Buffer('über', 'ascii');
-assert.deepEqual(f, new Buffer([252, 98, 101, 114]));
\ No newline at end of file
+assert.deepEqual(f, new Buffer([252, 98, 101, 114]));
index 10ec8f8..f6662a2 100644 (file)
@@ -10,12 +10,12 @@ function pwd (callback) {
 
   child.stdout.setEncoding('utf8');
   child.stdout.addListener("data", function (s) {
-    puts("stdout: " + JSON.stringify(s));
+    console.log("stdout: " + JSON.stringify(s));
     output += s;
   });
 
   child.addListener("exit", function (c) {
-    puts("exit: " + c);
+    console.log("exit: " + c);
     assert.equal(0, c);
     callback(output);
     pwd_called = true;
index d645010..39e704b 100644 (file)
@@ -17,7 +17,7 @@ var expected = "hello world";
 var helloPath = fixtPath("hello.txt");
 
 function test1(next) {
-  puts("Test 1...");
+  console.log("Test 1...");
   fs.open(helloPath, 'w', 400, function (err, fd) {
     if (err) throw err;
     var child = spawn('/bin/echo', [expected], undefined, [-1, fd] );
@@ -34,7 +34,7 @@ function test1(next) {
         fs.readFile(helloPath, function (err, data) {
           if (err) throw err;
           assert.equal(data.toString(), expected + "\n");
-          puts('  File was written.');
+          console.log('  File was written.');
           next(test3);
         });
       });
@@ -45,7 +45,7 @@ function test1(next) {
 // Test the equivalent of:
 // $ node ../fixture/stdio-filter.js < hello.txt
 function test2(next) {
-  puts("Test 2...");
+  console.log("Test 2...");
   fs.open(helloPath, 'r', undefined, function (err, fd) {
     var child = spawn(process.argv[0]
                      , [fixtPath('stdio-filter.js'), 'o', 'a']
@@ -59,7 +59,7 @@ function test2(next) {
     child.addListener('exit', function (code) {
       if (err) throw err;
       assert.equal(actualData, "hella warld\n");
-      puts("  File was filtered successfully");
+      console.log("  File was filtered successfully");
       fs.close(fd, function () {
         next(test3);
       });
@@ -70,19 +70,19 @@ function test2(next) {
 // Test the equivalent of:
 // $ /bin/echo "hello world" | ../stdio-filter.js a o
 function test3(next) {
-  puts("Test 3...");
+  console.log("Test 3...");
   var filter = spawn(process.argv[0]
                    , [fixtPath('stdio-filter.js'), 'o', 'a']);
   var echo = spawn('/bin/echo', [expected], undefined, [-1, filter.fds[0]]);
   var actualData = '';
   filter.stdout.addListener('data', function(data) {
-    puts("  Got data --> " + data);
+    console.log("  Got data --> " + data);
     actualData += data;
   });
   filter.addListener('exit', function(code) {
     if (code) throw "Return code was " + code;
     assert.equal(actualData, "hella warld\n");
-    puts("  Talked to another process successfully");
+    console.log("  Talked to another process successfully");
   });
   echo.addListener('exit', function(code) {
     if (code) throw "Return code was " + code;
@@ -91,4 +91,4 @@ function test3(next) {
   });
 }
 
-test1(test2);
\ No newline at end of file
+test1(test2);
index d6f9674..5a02448 100644 (file)
@@ -8,7 +8,7 @@ response = "";
 child.stdout.setEncoding('utf8');
 
 child.stdout.addListener("data", function (chunk) {
-  puts("stdout: " + chunk);
+  console.log("stdout: " + chunk);
   response += chunk;
 });
 
index 3b98812..f148276 100644 (file)
@@ -12,13 +12,13 @@ var gotEcho = false;
 var child = spawn(process.argv[0], [sub]);
 
 child.stderr.addListener("data", function (data){
-  puts("parent stderr: " + data);
+  console.log("parent stderr: " + data);
 });
 
 child.stdout.setEncoding('utf8');
 
 child.stdout.addListener("data", function (data){
-  puts('child said: ' + JSON.stringify(data));
+  console.log('child said: ' + JSON.stringify(data));
   if (!gotHelloWorld) {
     assert.equal("hello world\r\n", data);
     gotHelloWorld = true;
@@ -31,7 +31,7 @@ child.stdout.addListener("data", function (data){
 });
 
 child.stdout.addListener("end", function (data){
-  puts('child end');
+  console.log('child end');
 });
 
 
index 6521f43..730ae5c 100644 (file)
@@ -15,7 +15,7 @@ var gotStdoutEOF = false;
 
 cat.stdout.setEncoding('utf8');
 cat.stdout.addListener("data", function (chunk) {
-  puts("stdout: " + chunk);
+  console.log("stdout: " + chunk);
   response += chunk;
 });
 
@@ -37,7 +37,7 @@ cat.stderr.addListener("end", function (chunk) {
 
 
 cat.addListener("exit", function (status) {
-  puts("exit event");
+  console.log("exit event");
   exitStatus = status;
   assert.equal("hello world", response);
 });
index 25c5118..00cdbe0 100644 (file)
@@ -11,17 +11,17 @@ var count = 0;
 
 child.stderr.setEncoding('utf8');
 child.stderr.addListener("data", function (data) {
-  puts("parent stderr: " + data);
+  console.log("parent stderr: " + data);
   assert.ok(false);
 });
 
 child.stderr.setEncoding('utf8');
 child.stdout.addListener("data", function (data) {
   count += data.length;
-  puts(count);
+  console.log(count);
 });
 
 child.addListener("exit", function (data) {
   assert.equal(n, count);
-  puts("okay");
+  console.log("okay");
 });
index 08f3e78..2cf052b 100644 (file)
@@ -3,7 +3,7 @@ require("../common");
 try {
   var crypto = require('crypto');
 } catch (e) {
-  puts("Not compiled with OPENSSL support.");
+  console.log("Not compiled with OPENSSL support.");
   process.exit();
 } 
 
index a450f73..88e61cc 100644 (file)
@@ -12,9 +12,9 @@ function pingPongTest (port, host) {
   var sent_final_ping = false;
 
   var server = dgram.createSocket(function (msg, rinfo) {
-    puts("connection: " + rinfo.address + ":"+ rinfo.port);
+    console.log("connection: " + rinfo.address + ":"+ rinfo.port);
 
-    puts("server got: " + msg);
+    console.log("server got: " + msg);
 
     if (/PING/.exec(msg)) {
       var buf = new Buffer(4);
@@ -33,7 +33,7 @@ function pingPongTest (port, host) {
   server.bind(port, host);
 
   server.addListener("listening", function () {
-    puts("server listening on " + port + " " + host);
+    console.log("server listening on " + port + " " + host);
 
     var buf = new Buffer(4);
     buf.write('PING');
@@ -41,7 +41,7 @@ function pingPongTest (port, host) {
     var client = dgram.createSocket();
 
     client.addListener("message", function (msg, rinfo) {
-      puts("client got: " + msg);
+      console.log("client got: " + msg);
       assert.equal("PONG", msg.toString('ascii'));
 
       count += 1;
@@ -58,7 +58,7 @@ function pingPongTest (port, host) {
     });
 
     client.addListener("close", function () {
-      puts('client.close');
+      console.log('client.close');
       assert.equal(N, count);
       tests_run += 1;
       server.close();
@@ -84,5 +84,5 @@ pingPongTest(20997, "::1");
 
 process.addListener("exit", function () {
   assert.equal(4, tests_run);
-  puts('done');
+  console.log('done');
 });
index 5804959..387cc79 100644 (file)
@@ -4,19 +4,19 @@ var count = 100;
 var fs = require('fs');
 
 function tryToKillEventLoop() {
-  puts('trying to kill event loop ...');
+  console.log('trying to kill event loop ...');
 
   fs.stat(__filename, function (err) {
     if (err) {
       throw new Exception('first fs.stat failed')
     } else {
-      puts('first fs.stat succeeded ...');
+      console.log('first fs.stat succeeded ...');
       fs.stat(__filename, function (err) {
         if (err) {
           throw new Exception('second fs.stat failed')
         } else {
-          puts('second fs.stat succeeded ...');
-          puts('could not kill event loop, retrying...');
+          console.log('second fs.stat succeeded ...');
+          console.log('could not kill event loop, retrying...');
 
           setTimeout(function () {
             if (--count) {
@@ -41,7 +41,7 @@ fs.open('/dev/zero', "r", 0666, function (err, fd) {
       if (err) throw err;
       if (chunk) {
         pos += bytesRead;
-        //puts(pos);
+        //console.log(pos);
         readChunk();
       } else {
         fs.closeSync(fd);
index 3749789..207a592 100644 (file)
@@ -8,13 +8,13 @@ setTimeout(function () {
   // require() calls..
   N = 30;
   for (var i=0; i < N; i++) {
-    puts("start " + i);
+    console.log("start " + i);
     fs.readFile(testTxt, function(err, data) {
       if (err) {
-        puts("error! " + e);
+        console.log("error! " + e);
         process.exit(1);
       } else {
-        puts("finish");
+        console.log("finish");
       }
     });
   }
index 2109aba..21402c8 100644 (file)
@@ -8,7 +8,7 @@ for (var i = 0; i < N; i++) {
   fs.stat("does-not-exist-" + i, function (err) {
     if (err) {
       j++; // only makes it to about 17
-      puts("finish " + j);
+      console.log("finish " + j);
     } else {
       throw new Error("this shouldn't be called");
     }
index aa02de9..46c8982 100644 (file)
@@ -22,7 +22,7 @@ function errExec (script, callback) {
     // Count the tests
     exits++;
 
-    puts('.');
+    console.log('.');
   });
 }
 
index cdb9db7..3583fb1 100644 (file)
@@ -7,18 +7,18 @@ var events_new_listener_emited = [];
 var times_hello_emited = 0;
 
 e.addListener("newListener", function (event, listener) {
-  puts("newListener: " + event);
+  console.log("newListener: " + event);
   events_new_listener_emited.push(event);
 });
 
 e.addListener("hello", function (a, b) {
-  puts("hello");
+  console.log("hello");
   times_hello_emited += 1
   assert.equal("a", a);
   assert.equal("b", b);
 });
 
-puts("start");
+console.log("start");
 
 e.emit("hello", "a", "b");
 
index 87451c4..b7fdc6d 100644 (file)
@@ -5,17 +5,17 @@ var events = require('events');
 count = 0;
 
 function listener1 () {
-  puts('listener1');
+  console.log('listener1');
   count++;
 }
 
 function listener2 () {
-  puts('listener2');
+  console.log('listener2');
   count++;
 }
 
 function listener3 () {
-  puts('listener3');
+  console.log('listener3');
   count++;
 }
 
index 61f9222..957e038 100644 (file)
@@ -4,13 +4,13 @@ var MESSAGE = 'catch me if you can';
 var caughtException = false;
 
 process.addListener('uncaughtException', function (e) {
-  puts("uncaught exception! 1");
+  console.log("uncaught exception! 1");
   assert.equal(MESSAGE, e.message);
   caughtException = true;
 });
 
 process.addListener('uncaughtException', function (e) {
-  puts("uncaught exception! 2");
+  console.log("uncaught exception! 2");
   assert.equal(MESSAGE, e.message);
   caughtException = true;
 });
@@ -20,6 +20,6 @@ setTimeout(function() {
 }, 10);
 
 process.addListener("exit", function () {
-  puts("exit");
+  console.log("exit");
   assert.equal(true, caughtException);
 });
index 8e92c98..0625c19 100644 (file)
@@ -6,9 +6,9 @@ error_count = 0;
 exec("ls /", function (err, stdout, stderr) {
   if (err) {
     error_count++;
-    puts("error!: " + err.code);
-    puts("stdout: " + JSON.stringify(stdout));
-    puts("stderr: " + JSON.stringify(stderr));
+    console.log("error!: " + err.code);
+    console.log("stdout: " + JSON.stringify(stdout));
+    console.log("stderr: " + JSON.stringify(stderr));
     assert.equal(false, err.killed);
   } else {
     success_count++;
@@ -24,9 +24,9 @@ exec("ls /DOES_NOT_EXIST", function (err, stdout, stderr) {
     assert.equal(true, err.code != 0);
     assert.equal(false, err.killed);
     assert.strictEqual(null, err.signal);
-    puts("error code: " + err.code);
-    puts("stdout: " + JSON.stringify(stdout));
-    puts("stderr: " + JSON.stringify(stderr));
+    console.log("error code: " + err.code);
+    console.log("stdout: " + JSON.stringify(stdout));
+    console.log("stderr: " + JSON.stringify(stderr));
   } else {
     success_count++;
     p(stdout);
index 7b59d4f..1093621 100644 (file)
@@ -12,8 +12,8 @@ nodePath = path.join(__dirname,
                      isDebug ? 'node_g' : 'node');
 nodePath = path.normalize(nodePath);
 
-puts('nodePath: ' + nodePath);
-puts('process.execPath: ' + process.execPath);
+console.log('nodePath: ' + nodePath);
+console.log('process.execPath: ' + process.execPath);
 
 
 assert.equal(nodePath, process.execPath);
index 13cd7f9..8589c0b 100644 (file)
@@ -15,6 +15,6 @@ fs.readFile(filename, "raw", function (err, content) {
 });
 
 process.addListener("exit", function () {
-  puts("done");
+  console.log("done");
   assert.equal(true, got_error);
 });
index f8c4d71..732f29b 100644 (file)
@@ -10,7 +10,7 @@ fs.chmod(file, 0777, function (err) {
   if (err) {
     got_error = true;
   } else {
-    puts(fs.statSync(file).mode);
+    console.log(fs.statSync(file).mode);
     assert.equal(0777, fs.statSync(file).mode & 0777);
     
     fs.chmodSync(file, 0644);
index 5a18177..7d4ebbf 100644 (file)
@@ -22,4 +22,4 @@ assert.equal(r, expected.length);
 
 process.addListener('exit', function() {
   assert.equal(readCalled, 1);
-});
\ No newline at end of file
+});
index 7f9bf48..bb23bc9 100644 (file)
@@ -20,4 +20,4 @@ assert.equal(r[1], expected.length);
 
 process.addListener('exit', function() {
   assert.equal(readCalled, 1);
-});
\ No newline at end of file
+});
index 8073fb5..fec0cd7 100644 (file)
@@ -7,4 +7,4 @@ var
 
 fs.readFile(fn, function(err, data) {
   assert.ok(data);
-});
\ No newline at end of file
+});
index 2bf444e..6a6a70f 100644 (file)
@@ -241,7 +241,7 @@ var numtests = tests.length;
 function runNextTest(err) {
   if (err) throw err;
   var test = tests.shift()
-  if (!test) puts(numtests+' subtests completed OK for fs.realpath');
+  if (!test) console.log(numtests+' subtests completed OK for fs.realpath');
   else test(runNextTest);
 }
 runNextTest();
index eb19251..c063eb9 100644 (file)
@@ -56,7 +56,7 @@ fs.open(".", "r", undefined, function(err, fd) {
   fs.close(fd);
 });
 
-puts("stating: " + __filename);
+console.log("stating: " + __filename);
 fs.stat(__filename, function (err, s) {
   if (err) {
     got_error = true;
@@ -64,25 +64,25 @@ fs.stat(__filename, function (err, s) {
     p(s);
     success_count++;
 
-    puts("isDirectory: " + JSON.stringify( s.isDirectory() ) );
+    console.log("isDirectory: " + JSON.stringify( s.isDirectory() ) );
     assert.equal(false, s.isDirectory());
 
-    puts("isFile: " + JSON.stringify( s.isFile() ) );
+    console.log("isFile: " + JSON.stringify( s.isFile() ) );
     assert.equal(true, s.isFile());
 
-    puts("isSocket: " + JSON.stringify( s.isSocket() ) );
+    console.log("isSocket: " + JSON.stringify( s.isSocket() ) );
     assert.equal(false, s.isSocket());
 
-    puts("isBlockDevice: " + JSON.stringify( s.isBlockDevice() ) );
+    console.log("isBlockDevice: " + JSON.stringify( s.isBlockDevice() ) );
     assert.equal(false, s.isBlockDevice());
 
-    puts("isCharacterDevice: " + JSON.stringify( s.isCharacterDevice() ) );
+    console.log("isCharacterDevice: " + JSON.stringify( s.isCharacterDevice() ) );
     assert.equal(false, s.isCharacterDevice());
 
-    puts("isFIFO: " + JSON.stringify( s.isFIFO() ) );
+    console.log("isFIFO: " + JSON.stringify( s.isFIFO() ) );
     assert.equal(false, s.isFIFO());
 
-    puts("isSymbolicLink: " + JSON.stringify( s.isSymbolicLink() ) );
+    console.log("isSymbolicLink: " + JSON.stringify( s.isSymbolicLink() ) );
     assert.equal(false, s.isSymbolicLink());
 
     assert.ok(s.mtime instanceof Date);
index f7363eb..b35d3fe 100644 (file)
@@ -9,7 +9,7 @@ var linkPath = path.join(fixturesDir, "nested-index", 'one', 'symlink1.js');
 try {fs.unlinkSync(linkPath);}catch(e){}
 fs.symlink(linkData, linkPath, function(err){
   if (err) throw err;
-  puts('symlink done');
+  console.log('symlink done');
   // todo: fs.lstat?
   fs.readlink(linkPath, function(err, destination) {
     if (err) throw err;
@@ -24,7 +24,7 @@ var dstPath = path.join(fixturesDir, "nested-index", 'one', 'link1.js');
 try {fs.unlinkSync(dstPath);}catch(e){}
 fs.link(srcPath, dstPath, function(err){
   if (err) throw err;
-  puts('hard link done');
+  console.log('hard link done');
   var srcContent = fs.readFileSync(srcPath, 'utf8');
   var dstContent = fs.readFileSync(dstPath, 'utf8');
   assert.equal(srcContent, dstContent);
index 24a8b8c..3c7004d 100644 (file)
@@ -8,15 +8,15 @@ var found;
 
 fs.open(fn, 'w', 0644, function (err, fd) {
   if (err) throw err;
-  puts('open done');
+  console.log('open done');
   fs.write(fd, expected, 0, "utf8", function (err, written) {
-    puts('write done');
+    console.log('write done');
     if (err) throw err;
     assert.equal(Buffer.byteLength(expected), written);
     fs.closeSync(fd);
     found = fs.readFileSync(fn, 'utf8');
-    puts('expected: ' + expected.toJSON());
-    puts('found: ' + found.toJSON());
+    console.log('expected: ' + expected.toJSON());
+    console.log('found: ' + found.toJSON());
     fs.unlinkSync(fn);
   });
 });
index 534a408..c284135 100644 (file)
@@ -24,7 +24,7 @@ c.addListener("connect", function () {
 });
 
 c.addListener("data", function (chunk) {
-  puts(chunk);
+  console.log(chunk);
   server_response += chunk;
 });
 
index e71befc..1d986c1 100644 (file)
@@ -18,4 +18,4 @@ s.listen(PORT, function () {
   });
 });
 
-sys.puts('Server running at http://127.0.0.1:'+PORT+'/')
+console.log('Server running at http://127.0.0.1:'+PORT+'/')
index 69787eb..5bb778d 100644 (file)
@@ -3,7 +3,7 @@ http = require("http");
 
 var body = "exports.A = function() { return 'A';}";
 var server = http.createServer(function (req, res) {
-  puts("got request");
+  console.log("got request");
   res.writeHead(200, [
     ["Content-Length", body.length],
     ["Content-Type", "text/plain"]
@@ -19,7 +19,7 @@ server.listen(PORT, function () {
     if (err) {
       throw err;
     } else {
-      puts("got response");
+      console.log("got response");
       got_good_server_content = true;
       assert.equal(body, content);
       server.close();
@@ -28,14 +28,14 @@ server.listen(PORT, function () {
 
   http.cat("http://localhost:12312/", "utf8", function (err, content) {
     if (err) { 
-      puts("got error (this should happen)");
+      console.log("got error (this should happen)");
       bad_server_got_error = true;
     } 
   });
 });
 
 process.addListener("exit", function () {
-  puts("exit");
+  console.log("exit");
   assert.equal(true, got_good_server_content);
   assert.equal(true, bad_server_got_error);
 });
index b1168eb..14f0265 100644 (file)
@@ -12,8 +12,8 @@ server.listen(PORT);
 http.cat("http://127.0.0.1:"+PORT+"/", "utf8", function (err, data) {
   if (err) throw err;
   assert.equal('string', typeof data);
-  puts('here is the response:');
+  console.log('here is the response:');
   assert.equal(UTF8_STRING, data);
-  puts(data);
+  console.log(data);
   server.close();
 })
index 82fd890..8627cdc 100644 (file)
@@ -10,13 +10,13 @@ var server = http.createServer(function(req, res) {
   req.setBodyEncoding("utf8");
 
   req.addListener('data', function (chunk) {
-    puts("server got: " + JSON.stringify(chunk));
+    console.log("server got: " + JSON.stringify(chunk));
     sent_body += chunk;
   });
 
   req.addListener('end', function () {
     server_req_complete = true;
-    puts("request complete from server");
+    console.log("request complete from server");
     res.writeHead(200, {'Content-Type': 'text/plain'});
     res.write('hello\n');
     res.end();
@@ -36,7 +36,7 @@ error("client finished sending request");
 req.addListener('response', function(res) {
   res.setEncoding("utf8");
   res.addListener('data', function(chunk) {
-    puts(chunk);
+    console.log(chunk);
   });
   res.addListener('end', function() {
     client_res_complete = true;
index b373f8f..71bd091 100644 (file)
@@ -21,7 +21,7 @@ function check_reqs() {
     }
   });
   if (done_reqs === 4) {
-    sys.puts("Got all requests, which is bad.");
+    console.log("Got all requests, which is bad.");
     clearTimeout(timer);
   }
 }
@@ -60,7 +60,7 @@ server.listen(PORT, function () {
 });
 
 function exception_handler(err) {
-  sys.puts("Caught an exception: " + err);
+  console.log("Caught an exception: " + err);
   if (err.name === "AssertionError") {
     throw(err);
   }
index 6898805..095ee3d 100644 (file)
@@ -22,7 +22,7 @@ function runAb(opts, callback) {
   var command = "ab " + opts + " http://127.0.0.1:" + PORT + "/";
   exec(command, function (err, stdout, stderr) {
     if (err) {
-      puts("ab not installed? skipping test.\n" + stderr);
+      console.log("ab not installed? skipping test.\n" + stderr);
       process.exit();
       return;
     }
@@ -47,13 +47,13 @@ function runAb(opts, callback) {
 
 server.listen(PORT, function () {
   runAb("-c 1 -n 10", function () {
-    puts("-c 1 -n 10 okay");
+    console.log("-c 1 -n 10 okay");
 
     runAb("-c 1 -n 100", function () {
-      puts("-c 1 -n 100 okay");
+      console.log("-c 1 -n 100 okay");
 
       runAb("-c 1 -n 1000", function () {
-        puts("-c 1 -n 1000 okay");
+        console.log("-c 1 -n 1000 okay");
         server.close();
       });
     });
index e93fba9..7145527 100644 (file)
@@ -10,7 +10,7 @@ nrequests_completed = 0;
 nrequests_expected = 1;
 
 var s = http.createServer(function (req, res) {
-  puts("req: " + JSON.stringify(url.parse(req.url)));
+  console.log("req: " + JSON.stringify(url.parse(req.url)));
 
   res.writeHead(200, {"Content-Type": "text/plain"});
   res.write("Hello World");
index e524cd0..159aefd 100644 (file)
@@ -19,12 +19,12 @@ buffer.asciiWrite(request, 0, request.length);
 var callbacks = 0;
 
 parser.onMessageBegin = function () {
-  puts("message begin");
+  console.log("message begin");
   callbacks++;
 };
 
 parser.onHeadersComplete = function (info) {
-  puts("headers complete: " + JSON.stringify(info));
+  console.log("headers complete: " + JSON.stringify(info));
   assert.equal('GET', info.method);
   assert.equal(1, info.versionMajor);
   assert.equal(1, info.versionMinor);
@@ -37,9 +37,9 @@ parser.onURL = function (b, off, len) {
 };
 
 parser.onPath = function (b, off, length) {
-  puts("path [" + off + ", " + length + "]");
+  console.log("path [" + off + ", " + length + "]");
   var path = b.asciiSlice(off, off+length);
-  puts("path = '" + path + "'");
+  console.log("path = '" + path + "'");
   assert.equal('/hello', path);
   callbacks++;
 };
index fdf5918..d15044d 100644 (file)
@@ -3,7 +3,7 @@ var sys = require('sys'),
    http = require('http');
 
 server = http.createServer(function (req, res) {
-  sys.puts('got request. setting 1 second timeout');
+  console.log('got request. setting 1 second timeout');
   req.connection.setTimeout(500);
 
   req.connection.addListener('timeout', function(){
@@ -13,7 +13,7 @@ server = http.createServer(function (req, res) {
 });
 
 server.listen(PORT, function () {
-  sys.puts('Server running at http://127.0.0.1:'+PORT+'/');
+  console.log('Server running at http://127.0.0.1:'+PORT+'/');
 
   errorTimer =setTimeout(function () {
     throw new Error('Timeout was not sucessful');
@@ -21,6 +21,6 @@ server.listen(PORT, function () {
 
   http.cat('http://localhost:'+PORT+'/', 'utf8', function (err, content) {
     clearTimeout(errorTimer);
-    sys.puts('HTTP REQUEST COMPLETE (this is good)');
+    console.log('HTTP REQUEST COMPLETE (this is good)');
   });
 });
index 11845da..db4ce90 100644 (file)
@@ -14,7 +14,7 @@ try {
   have_openssl=true;
 } catch (e) {
   have_openssl=false;
-  puts("Not compiled with OPENSSL support.");
+  console.log("Not compiled with OPENSSL support.");
   process.exit();
 } 
 
@@ -61,7 +61,7 @@ var https_server = http.createServer(function (req, res) {
   if (req.id == 3) {
     assert.equal("bar", req.headers['x-x']);
     this.close();
-    //puts("server closed");
+    //console.log("server closed");
   }
   setTimeout(function () {
     res.writeHead(200, {"Content-Type": "text/plain"});
index 47e215e..98ea43f 100644 (file)
@@ -39,19 +39,19 @@ c.addListener("connect", function () {
 });
 
 c.addListener("data", function (chunk) {
-  puts(chunk);
+  console.log(chunk);
   server_response += chunk;
 });
 
 c.addListener("end", function () {
   client_got_eof = true;
-  puts('got end');
+  console.log('got end');
   c.end();
 });
 
 c.addListener("close", function () {
   connection_was_closed = true;
-  puts('got close');
+  console.log('got close');
   server.close();
 });
 
index 2ccce59..3b430c8 100644 (file)
@@ -5,7 +5,7 @@ http = require('http');
 assert = require('assert');
 
 server = http.createServer(function (request, response) {
-  sys.puts('responding to ' + request.url);
+  console.log('responding to ' + request.url);
 
   response.writeHead(200, {'Content-Type': 'text/plain'});
   response.write('1\n');
index 8efe0f5..0d45546 100644 (file)
@@ -1,6 +1,6 @@
 require("../common");
 
 var r = process.memoryUsage();
-puts(inspect(r));
+console.log(inspect(r));
 assert.equal(true, r["rss"] > 0);
 assert.equal(true, r["vsize"] > 0);
index 1464370..1a31bf3 100644 (file)
@@ -11,16 +11,16 @@ var rmdir_error = false;
 
 fs.mkdir(d, 0666, function (err) {
   if (err) {
-    puts("mkdir error: " + err.message);
+    console.log("mkdir error: " + err.message);
     mkdir_error = true;
   } else {
-    puts("mkdir okay!");
+    console.log("mkdir okay!");
     fs.rmdir(d, function (err) {
       if (err) {
-        puts("rmdir error: " + err.message);
+        console.log("rmdir error: " + err.message);
         rmdir_error = true;
       } else {
-        puts("rmdir okay!");
+        console.log("rmdir okay!");
       }
     });
   }
@@ -29,5 +29,5 @@ fs.mkdir(d, 0666, function (err) {
 process.addListener("exit", function () {
   assert.equal(false, mkdir_error);
   assert.equal(false, rmdir_error);
-  puts("exit");
+  console.log("exit");
 });
index 460c794..220c3d1 100644 (file)
@@ -113,5 +113,5 @@ process.addListener("exit", function () {
 
   assert.equal(true, errorThrownAsync);
 
-  puts("exit");
+  console.log("exit");
 });
index 9dc347a..ad6f4f0 100644 (file)
@@ -57,17 +57,17 @@ c.addListener("close", function () {
 });
 
 process.addListener("exit", function () {
-  puts("recv: " + JSON.stringify(recv));
+  console.log("recv: " + JSON.stringify(recv));
 
   assert.equal(2*256, recv.length);
 
   var a = recv.split("");
 
   var first = a.slice(0,256).reverse().join("");
-  puts("first: " + JSON.stringify(first));
+  console.log("first: " + JSON.stringify(first));
 
   var second = a.slice(256,2*256).join("");
-  puts("second: " + JSON.stringify(second));
+  console.log("second: " + JSON.stringify(second));
 
   assert.equal(first, second);
 });
index d715e2c..cc8a0c2 100644 (file)
@@ -10,7 +10,7 @@ function pingPongTest (port, host) {
   var sent_final_ping = false;
 
   var server = net.createServer(function (socket) {
-    puts("connection: " + socket.remoteAddress);
+    console.log("connection: " + socket.remoteAddress);
     assert.equal(server, socket.server);
 
     socket.setNoDelay();
@@ -18,7 +18,7 @@ function pingPongTest (port, host) {
 
     socket.setEncoding('utf8');
     socket.addListener("data", function (data) {
-      puts("server got: " + data);
+      console.log("server got: " + data);
       assert.equal(true, socket.writable);
       assert.equal(true, socket.readable);
       assert.equal(true, count <= N);
@@ -38,7 +38,7 @@ function pingPongTest (port, host) {
     });
 
     socket.addListener("close", function () {
-      puts('server socket.endd');
+      console.log('server socket.endd');
       assert.equal(false, socket.writable);
       assert.equal(false, socket.readable);
       socket.server.close();
@@ -47,7 +47,7 @@ function pingPongTest (port, host) {
 
 
   server.listen(port, host, function () {
-    puts("server listening on " + port + " " + host);
+    console.log("server listening on " + port + " " + host);
 
     var client = net.createConnection(port, host);
 
@@ -59,7 +59,7 @@ function pingPongTest (port, host) {
     });
 
     client.addListener("data", function (data) {
-      puts("client got: " + data);
+      console.log("client got: " + data);
 
       assert.equal("PONG", data);
       count += 1;
@@ -83,7 +83,7 @@ function pingPongTest (port, host) {
     });
 
     client.addListener("close", function () {
-      puts('client.endd');
+      console.log('client.endd');
       assert.equal(N+1, count);
       assert.equal(true, sent_final_ping);
       tests_run += 1;
@@ -103,5 +103,5 @@ pingPongTest("/tmp/pingpong.sock");
 
 process.addListener("exit", function () {
   assert.equal(4, tests_run);
-  puts('done');
+  console.log('done');
 });
index 9b297a7..b5be64d 100644 (file)
@@ -16,30 +16,30 @@ var server = net.createServer(function (socket) {
   });
 
   socket.addListener("close", function (had_error) {
-    //puts("server had_error: " + JSON.stringify(had_error));
+    //console.log("server had_error: " + JSON.stringify(had_error));
     assert.equal(false, had_error);
   });
 });
 
 server.listen(PORT, function () {
-  puts('listening');
+  console.log('listening');
   var client = net.createConnection(PORT);
 
   client.setEncoding("UTF8");
 
   client.addListener("connect", function () {
-    puts("client connected.");
+    console.log("client connected.");
   });
 
   client.addListener("data", function (chunk) {
     client_recv_count += 1;
-    puts("client_recv_count " + client_recv_count);
+    console.log("client_recv_count " + client_recv_count);
     assert.equal("hello\r\n", chunk);
     client.end();
   });
 
   client.addListener("close", function (had_error) {
-    puts("disconnect");
+    console.log("disconnect");
     assert.equal(false, had_error);
     if (disconnect_count++ < N)
       client.connect(PORT); // reconnect
index a5633d0..b6c1d11 100644 (file)
@@ -9,7 +9,7 @@ try {
   have_openssl=true;
 } catch (e) {
   have_openssl=false;
-  puts("Not compiled with OPENSSL support.");
+  console.log("Not compiled with OPENSSL support.");
   process.exit();
 } 
 
index ee41f05..b08e227 100644 (file)
@@ -6,13 +6,13 @@ var done = [];
 
 function get_printer(timeout) {
   return function () {
-    sys.puts("Running from setTimeout " + timeout);
+    console.log("Running from setTimeout " + timeout);
     done.push(timeout);
   };
 }
 
 process.nextTick(function () {
-  sys.puts("Running from nextTick");
+  console.log("Running from nextTick");
   done.push('nextTick');
 })
 
@@ -20,7 +20,7 @@ for (i = 0; i < N; i += 1) {
   setTimeout(get_printer(i), i);
 }
 
-sys.puts("Running from main.");
+console.log("Running from main.");
 
 
 process.addListener('exit', function () {
index c90fe37..b1881fc 100644 (file)
@@ -16,16 +16,16 @@ var files = ['are'
             ];
 
 
-puts('readdirSync ' + readdirDir);
+console.log('readdirSync ' + readdirDir);
 var f = fs.readdirSync(readdirDir);
 p(f);
 assert.deepEqual(files, f.sort());
 
 
-puts("readdir " + readdirDir);
+console.log("readdir " + readdirDir);
 fs.readdir(readdirDir, function (err, f) {
   if (err) {
-    puts("error");
+    console.log("error");
     got_error = true;
   } else {
     p(f);
@@ -35,5 +35,5 @@ fs.readdir(readdirDir, function (err, f) {
 
 process.addListener("exit", function () {
   assert.equal(false, got_error);
-  puts("exit");
+  console.log("exit");
 });
index 7c6f451..913e120 100644 (file)
@@ -1,8 +1,8 @@
 var sys = require('sys');
 
-//sys.puts('puts before');
+//console.log('puts before');
 
 Object.prototype.xadsadsdasasdxx = function () {
 };
 
-sys.puts('puts after');
+console.log('puts after');
index 5e772d1..50d37c0 100644 (file)
@@ -1,26 +1,26 @@
 require("../common");
 
-puts("process.pid: " + process.pid);
+console.log("process.pid: " + process.pid);
 
 var first = 0,
     second = 0;
 
 process.addListener('SIGUSR1', function () {
-  puts("Interrupted by SIGUSR1");
+  console.log("Interrupted by SIGUSR1");
   first += 1;
 });
 
 process.addListener('SIGUSR1', function () {
   second += 1;
   setTimeout(function () {
-    puts("End.");
+    console.log("End.");
     process.exit(0);
   }, 5);
 });
 
 i = 0;
 setInterval(function () {
-  puts("running process..." + ++i);
+  console.log("running process..." + ++i);
 
   if (i == 5) {
     process.kill(process.pid, "SIGUSR1");
index 29ce09d..ee4fcf8 100644 (file)
@@ -13,14 +13,14 @@ child.addListener('exit', function () {
 });
 
 setTimeout(function () {
-  sys.puts("Sending SIGINT");
+  console.log("Sending SIGINT");
   child.kill("SIGINT");
   setTimeout(function () {
-    sys.puts("Chance has been given to die");
+    console.log("Chance has been given to die");
     done = true;
     if (!childKilled) {
       // Cleanup
-      sys.puts("Child did not die on SIGINT, sending SIGTERM");
+      console.log("Child did not die on SIGINT, sending SIGTERM");
       child.kill("SIGTERM");
     }
   }, 200);
index 0c7e8f7..7e4a445 100644 (file)
@@ -13,7 +13,7 @@ string = "abc\nümlaut.\nsomething else\n"
        + "南越国是前203年至前111年存在于岭南地区的一个国家,国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n";
 
 
-puts(cmd + "\n\n");
+console.log(cmd + "\n\n");
 
 try {
   fs.unlinkSync(tmpFile);
@@ -25,7 +25,7 @@ childProccess.exec(cmd, function(err, stdout, stderr) {
   fs.unlinkSync(tmpFile);
 
   if (err) throw err;
-  puts(stdout);
+  console.log(stdout);
   assert.equal(stdout, "hello world\r\n" + string);
   assert.equal("", stderr);
 });
index 5c611bf..3df3bfa 100644 (file)
@@ -25,11 +25,11 @@ function test (size, useBuffer, cb) {
   childProccess.exec(cmd, function(err) {
     if (err) throw err;
 
-    puts('done!');
+    console.log('done!');
 
     var stat = fs.statSync(tmpFile);
 
-    puts(tmpFile + ' has ' + stat.size + ' bytes');
+    console.log(tmpFile + ' has ' + stat.size + ' bytes');
 
     assert.equal(size, stat.size);
     fs.unlinkSync(tmpFile);
@@ -40,9 +40,9 @@ function test (size, useBuffer, cb) {
 
 finished = false;
 test(1024*1024, false, function () {
-  puts("Done printing with string");
+  console.log("Done printing with string");
   test(1024*1024, true, function () {
-    puts("Done printing with buffer");
+    console.log("Done printing with buffer");
     finished = true;
   });
 });
index fd52675..1f61d5c 100644 (file)
@@ -59,5 +59,5 @@ for (var j = 2; j < buffer.length; j++) {
     print(".");
   }
 }
-puts(" crayon!");
+console.log(" crayon!");
 
index a3b46e1..6861c7e 100644 (file)
@@ -2,7 +2,7 @@ require("../common");
 
 // üäö
 
-puts("Σὲ γνωρίζω ἀπὸ τὴν κόψη");
+console.log("Σὲ γνωρίζω ἀπὸ τὴν κόψη");
 
 assert.equal(true,  /Hellö Wörld/.test("Hellö Wörld") );