From ba792ea2020f38ebf84925e740b42823b739d0d3 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 23 Jun 2010 17:40:51 -0700 Subject: [PATCH] :%s/sys.puts/console.log/g and there was much rejoicing --- benchmark/http_simple.js | 12 +- benchmark/run.js | 4 +- bin/node-repl | 6 +- doc/api.markdown | 250 +++++++++------------ doc/index.html | 5 +- src/node.js | 9 +- test/disabled/test-cat.js | 4 +- test/disabled/test-dns.js | 4 +- test/disabled/test-eio-race3.js | 6 +- test/disabled/test-http-big-proxy-responses.js | 4 +- test/disabled/test-http-head-request.js | 4 +- test/disabled/test-http-stress.js | 2 +- test/disabled/test-remote-module-loading.js | 2 +- test/disabled/tls_client.js | 10 +- test/disabled/tls_server.js | 4 +- test/fixtures/b/c.js | 2 +- test/fixtures/child_process_should_emit_error.js | 2 +- test/fixtures/cycles/folder/foo.js | 2 +- test/fixtures/cycles/root.js | 2 +- test/fixtures/exit.js | 2 +- test/fixtures/print-10-lines.js | 2 +- test/message/2100bytes.js | 2 +- test/message/hello_world.js | 2 +- .../message/undefined_reference_in_new_context.out | 10 +- test/pummel/test-child-process-spawn-loop.js | 2 +- test/pummel/test-http-client-reconnect-bug.js | 6 +- test/pummel/test-keep-alive.js | 6 +- test/pummel/test-net-many-clients.js | 6 +- test/pummel/test-net-pause.js | 8 +- test/pummel/test-net-pingpong-delay.js | 12 +- test/pummel/test-net-pingpong.js | 6 +- test/pummel/test-net-throttle.js | 10 +- test/pummel/test-net-timeout.js | 18 +- test/pummel/test-net-tls.js | 6 +- test/pummel/test-timers.js | 4 +- test/pummel/test-watch-file.js | 4 +- test/simple/test-buffer.js | 6 +- test/simple/test-child-process-buffering.js | 4 +- test/simple/test-child-process-custom-fds.js | 16 +- test/simple/test-child-process-env.js | 2 +- test/simple/test-child-process-ipc.js | 6 +- test/simple/test-child-process-stdin.js | 4 +- test/simple/test-child-process-stdout-flush.js | 6 +- test/simple/test-crypto.js | 2 +- test/simple/test-dgram-pingpong.js | 12 +- test/simple/test-eio-race.js | 10 +- test/simple/test-eio-race2.js | 6 +- test/simple/test-eio-race4.js | 2 +- test/simple/test-error-reporting.js | 2 +- test/simple/test-event-emitter-add-listeners.js | 6 +- test/simple/test-event-emitter-remove-listeners.js | 6 +- test/simple/test-exception-handler.js | 6 +- test/simple/test-exec.js | 12 +- test/simple/test-executable-path.js | 4 +- test/simple/test-file-read-noexist.js | 2 +- test/simple/test-fs-chmod.js | 2 +- test/simple/test-fs-read-buffer.js | 2 +- test/simple/test-fs-read.js | 2 +- test/simple/test-fs-readfile-empty.js | 2 +- test/simple/test-fs-realpath.js | 2 +- test/simple/test-fs-stat.js | 16 +- test/simple/test-fs-symlink.js | 4 +- test/simple/test-fs-write.js | 8 +- test/simple/test-http-1.0.js | 2 +- test/simple/test-http-304.js | 2 +- test/simple/test-http-cat.js | 8 +- test/simple/test-http-chunked.js | 4 +- test/simple/test-http-client-upload.js | 6 +- test/simple/test-http-exceptions.js | 4 +- test/simple/test-http-full-response.js | 8 +- test/simple/test-http-malformed-request.js | 2 +- test/simple/test-http-parser.js | 8 +- test/simple/test-http-set-timeout.js | 6 +- test/simple/test-http-tls.js | 4 +- test/simple/test-http-wget.js | 6 +- test/simple/test-http-write-empty-string.js | 2 +- test/simple/test-memory-usage.js | 2 +- test/simple/test-mkdir-rmdir.js | 10 +- test/simple/test-module-loading.js | 2 +- test/simple/test-net-binary.js | 6 +- test/simple/test-net-pingpong.js | 14 +- test/simple/test-net-reconnect.js | 10 +- test/simple/test-net-tls.js | 2 +- test/simple/test-next-tick-ordering.js | 6 +- test/simple/test-readdir.js | 8 +- test/simple/test-regression-object-prototype.js | 4 +- test/simple/test-signal-handler.js | 8 +- test/simple/test-signal-unregister.js | 6 +- test/simple/test-stdin-from-file.js | 4 +- test/simple/test-stdout-to-file.js | 8 +- test/simple/test-string-decoder.js | 2 +- test/simple/test-utf8-scripts.js | 2 +- 92 files changed, 352 insertions(+), 396 deletions(-) diff --git a/benchmark/http_simple.js b/benchmark/http_simple.js index 627835b..1ab9097 100644 --- a/benchmark/http_simple.js +++ b/benchmark/http_simple.js @@ -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+'/'); diff --git a/benchmark/run.js b/benchmark/run.js index 7917c76..b1479b6 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -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); }); }; diff --git a/bin/node-repl b/bin/node-repl index b2b5d6c..15ef58c 100755 --- a/bin/node-repl +++ b/bin/node-repl @@ -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(); diff --git a/doc/api.markdown b/doc/api.markdown index 19951e6..cfa90fb 100644 --- a/doc/api.markdown +++ b/doc/api.markdown @@ -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`: diff --git a/doc/index.html b/doc/index.html index 930c00c..ab9821e 100644 --- a/doc/index.html +++ b/doc/index.html @@ -42,13 +42,12 @@

-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/');
 

diff --git a/src/node.js b/src/node.js index 2b7b00b..ae098fd 100644 --- a/src/node.js +++ b/src/node.js @@ -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(); } diff --git a/test/disabled/test-cat.js b/test/disabled/test-cat.js index 19edc29..4f12327 100644 --- a/test/disabled/test-cat.js +++ b/test/disabled/test-cat.js @@ -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" diff --git a/test/disabled/test-dns.js b/test/disabled/test-dns.js index f92757a..631eb65 100644 --- a/test/disabled/test-dns.js +++ b/test/disabled/test-dns.js @@ -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]); } } diff --git a/test/disabled/test-eio-race3.js b/test/disabled/test-eio-race3.js index 8c70375..9f9f245 100644 --- a/test/disabled/test-eio-race3.js +++ b/test/disabled/test-eio-race3.js @@ -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(); diff --git a/test/disabled/test-http-big-proxy-responses.js b/test/disabled/test-http-big-proxy-responses.js index 9ddb966..f3925d3 100644 --- a/test/disabled/test-http-big-proxy-responses.js +++ b/test/disabled/test-http-big-proxy-responses.js @@ -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; diff --git a/test/disabled/test-http-head-request.js b/test/disabled/test-http-head-request.js index 671e3ae..5956df3 100644 --- a/test/disabled/test-http-head-request.js +++ b/test/disabled/test-http-head-request.js @@ -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); }); diff --git a/test/disabled/test-http-stress.js b/test/disabled/test-http-stress.js index 19a2baf..5d0eda3 100644 --- a/test/disabled/test-http-stress.js +++ b/test/disabled/test-http-stress.js @@ -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(); } }); diff --git a/test/disabled/test-remote-module-loading.js b/test/disabled/test-remote-module-loading.js index 00a0974..b098c3e 100644 --- a/test/disabled/test-remote-module-loading.js +++ b/test/disabled/test-remote-module-loading.js @@ -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(); }); diff --git a/test/disabled/tls_client.js b/test/disabled/tls_client.js index eba7a88..909ec7d 100644 --- a/test/disabled/tls_client.js +++ b/test/disabled/tls_client.js @@ -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."); }); diff --git a/test/disabled/tls_server.js b/test/disabled/tls_server.js index f89ee4b..5aef382 100644 --- a/test/disabled/tls_server.js +++ b/test/disabled/tls_server.js @@ -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(); diff --git a/test/fixtures/b/c.js b/test/fixtures/b/c.js index 6aaf186..ee7cd47 100644 --- a/test/fixtures/b/c.js +++ b/test/fixtures/b/c.js @@ -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"); }); diff --git a/test/fixtures/child_process_should_emit_error.js b/test/fixtures/child_process_should_emit_error.js index ba7a149..a777b6e 100644 --- a/test/fixtures/child_process_should_emit_error.js +++ b/test/fixtures/child_process_should_emit_error.js @@ -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'); }); }); diff --git a/test/fixtures/cycles/folder/foo.js b/test/fixtures/cycles/folder/foo.js index 3763a11..268a613 100644 --- a/test/fixtures/cycles/folder/foo.js +++ b/test/fixtures/cycles/folder/foo.js @@ -3,4 +3,4 @@ var root = require("./../root"); exports.hello = function () { return root.calledFromFoo(); -}; \ No newline at end of file +}; diff --git a/test/fixtures/cycles/root.js b/test/fixtures/cycles/root.js index b515639..d93488c 100644 --- a/test/fixtures/cycles/root.js +++ b/test/fixtures/cycles/root.js @@ -7,4 +7,4 @@ exports.sayHello = function () { }; exports.calledFromFoo = function () { return exports.hello; -}; \ No newline at end of file +}; diff --git a/test/fixtures/exit.js b/test/fixtures/exit.js index 6f85c5d..c6c8b82 100644 --- a/test/fixtures/exit.js +++ b/test/fixtures/exit.js @@ -1 +1 @@ -process.exit(process.argv[2] || 1); \ No newline at end of file +process.exit(process.argv[2] || 1); diff --git a/test/fixtures/print-10-lines.js b/test/fixtures/print-10-lines.js index fc6b8b5..c8e16d0 100644 --- a/test/fixtures/print-10-lines.js +++ b/test/fixtures/print-10-lines.js @@ -1,4 +1,4 @@ puts = require('sys').puts; for (var i = 0; i < 10; i++) { - puts('count ' + i); + console.log('count ' + i); } diff --git a/test/message/2100bytes.js b/test/message/2100bytes.js index f2c1aac..9418698 100644 --- a/test/message/2100bytes.js +++ b/test/message/2100bytes.js @@ -1,7 +1,7 @@ require('../common'); sys = require('sys'); -sys.puts([ +console.log([ '_______________________________________________50', '______________________________________________100', '______________________________________________150', diff --git a/test/message/hello_world.js b/test/message/hello_world.js index 2810b74..55b231e 100644 --- a/test/message/hello_world.js +++ b/test/message/hello_world.js @@ -1,3 +1,3 @@ require('../common'); -puts('hello world'); +console.log('hello world'); diff --git a/test/message/undefined_reference_in_new_context.out b/test/message/undefined_reference_in_new_context.out index fffe056..12c3ab5 100644 --- a/test/message/undefined_reference_in_new_context.out +++ b/test/message/undefined_reference_in_new_context.out @@ -7,8 +7,8 @@ script.runInNewContext(); ReferenceError: foo is not defined at evalmachine.:1:1 at Object. (*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:*:* diff --git a/test/pummel/test-child-process-spawn-loop.js b/test/pummel/test-child-process-spawn-loop.js index 76e4236..fb426ac 100644 --- a/test/pummel/test-child-process-spawn-loop.js +++ b/test/pummel/test-child-process-spawn-loop.js @@ -16,7 +16,7 @@ function doSpawn (i) { }); child.stderr.addListener("data", function (chunk) { - puts('stderr: ' + chunk); + console.log('stderr: ' + chunk); }); child.addListener("exit", function () { diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index a36a73f..4e74efd 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -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 () { diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index 235843a..4286783 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -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(); }); }); diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js index 9cff30b..fe026b9 100644 --- a/test/pummel/test-net-many-clients.js +++ b/test/pummel/test-net-many-clients.js @@ -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!"); }); diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js index de84c0e..0dbf65a 100644 --- a/test/pummel/test-net-pause.js +++ b/test/pummel/test-net-pause.js @@ -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(); diff --git a/test/pummel/test-net-pingpong-delay.js b/test/pummel/test-net-pingpong-delay.js index 5854674..6f18865 100644 --- a/test/pummel/test-net-pingpong-delay.js +++ b/test/pummel/test-net-pingpong-delay.js @@ -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(); diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index d96e398..a57234a 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -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; diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js index 8da7239..7205317 100644 --- a/test/pummel/test-net-throttle.js +++ b/test/pummel/test-net-throttle.js @@ -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); } diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js index 6e4600d..e1938ab 100644 --- a/test/pummel/test-net-timeout.js +++ b/test/pummel/test-net-timeout.js @@ -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); diff --git a/test/pummel/test-net-tls.js b/test/pummel/test-net-tls.js index d156b93..6d6dc31 100644 --- a/test/pummel/test-net-tls.js +++ b/test/pummel/test-net-tls.js @@ -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); } diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js index ce371fa..0aa470c 100644 --- a/test/pummel/test-timers.js +++ b/test/pummel/test-timers.js @@ -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; diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js index 3f50714..492177b 100644 --- a/test/pummel/test-watch-file.js +++ b/test/pummel/test-watch-file.js @@ -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); diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index 89a0148..949b5b8 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -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])); diff --git a/test/simple/test-child-process-buffering.js b/test/simple/test-child-process-buffering.js index 10ec8f8..f6662a2 100644 --- a/test/simple/test-child-process-buffering.js +++ b/test/simple/test-child-process-buffering.js @@ -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; diff --git a/test/simple/test-child-process-custom-fds.js b/test/simple/test-child-process-custom-fds.js index d645010..39e704b 100644 --- a/test/simple/test-child-process-custom-fds.js +++ b/test/simple/test-child-process-custom-fds.js @@ -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); diff --git a/test/simple/test-child-process-env.js b/test/simple/test-child-process-env.js index d6f9674..5a02448 100644 --- a/test/simple/test-child-process-env.js +++ b/test/simple/test-child-process-env.js @@ -8,7 +8,7 @@ response = ""; child.stdout.setEncoding('utf8'); child.stdout.addListener("data", function (chunk) { - puts("stdout: " + chunk); + console.log("stdout: " + chunk); response += chunk; }); diff --git a/test/simple/test-child-process-ipc.js b/test/simple/test-child-process-ipc.js index 3b98812..f148276 100644 --- a/test/simple/test-child-process-ipc.js +++ b/test/simple/test-child-process-ipc.js @@ -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'); }); diff --git a/test/simple/test-child-process-stdin.js b/test/simple/test-child-process-stdin.js index 6521f43..730ae5c 100644 --- a/test/simple/test-child-process-stdin.js +++ b/test/simple/test-child-process-stdin.js @@ -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); }); diff --git a/test/simple/test-child-process-stdout-flush.js b/test/simple/test-child-process-stdout-flush.js index 25c5118..00cdbe0 100644 --- a/test/simple/test-child-process-stdout-flush.js +++ b/test/simple/test-child-process-stdout-flush.js @@ -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"); }); diff --git a/test/simple/test-crypto.js b/test/simple/test-crypto.js index 08f3e78..2cf052b 100644 --- a/test/simple/test-crypto.js +++ b/test/simple/test-crypto.js @@ -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(); } diff --git a/test/simple/test-dgram-pingpong.js b/test/simple/test-dgram-pingpong.js index a450f73..88e61cc 100644 --- a/test/simple/test-dgram-pingpong.js +++ b/test/simple/test-dgram-pingpong.js @@ -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'); }); diff --git a/test/simple/test-eio-race.js b/test/simple/test-eio-race.js index 5804959..387cc79 100644 --- a/test/simple/test-eio-race.js +++ b/test/simple/test-eio-race.js @@ -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); diff --git a/test/simple/test-eio-race2.js b/test/simple/test-eio-race2.js index 3749789..207a592 100644 --- a/test/simple/test-eio-race2.js +++ b/test/simple/test-eio-race2.js @@ -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"); } }); } diff --git a/test/simple/test-eio-race4.js b/test/simple/test-eio-race4.js index 2109aba..21402c8 100644 --- a/test/simple/test-eio-race4.js +++ b/test/simple/test-eio-race4.js @@ -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"); } diff --git a/test/simple/test-error-reporting.js b/test/simple/test-error-reporting.js index aa02de9..46c8982 100644 --- a/test/simple/test-error-reporting.js +++ b/test/simple/test-error-reporting.js @@ -22,7 +22,7 @@ function errExec (script, callback) { // Count the tests exits++; - puts('.'); + console.log('.'); }); } diff --git a/test/simple/test-event-emitter-add-listeners.js b/test/simple/test-event-emitter-add-listeners.js index cdb9db7..3583fb1 100644 --- a/test/simple/test-event-emitter-add-listeners.js +++ b/test/simple/test-event-emitter-add-listeners.js @@ -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"); diff --git a/test/simple/test-event-emitter-remove-listeners.js b/test/simple/test-event-emitter-remove-listeners.js index 87451c4..b7fdc6d 100644 --- a/test/simple/test-event-emitter-remove-listeners.js +++ b/test/simple/test-event-emitter-remove-listeners.js @@ -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++; } diff --git a/test/simple/test-exception-handler.js b/test/simple/test-exception-handler.js index 61f9222..957e038 100644 --- a/test/simple/test-exception-handler.js +++ b/test/simple/test-exception-handler.js @@ -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); }); diff --git a/test/simple/test-exec.js b/test/simple/test-exec.js index 8e92c98..0625c19 100644 --- a/test/simple/test-exec.js +++ b/test/simple/test-exec.js @@ -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); diff --git a/test/simple/test-executable-path.js b/test/simple/test-executable-path.js index 7b59d4f..1093621 100644 --- a/test/simple/test-executable-path.js +++ b/test/simple/test-executable-path.js @@ -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); diff --git a/test/simple/test-file-read-noexist.js b/test/simple/test-file-read-noexist.js index 13cd7f9..8589c0b 100644 --- a/test/simple/test-file-read-noexist.js +++ b/test/simple/test-file-read-noexist.js @@ -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); }); diff --git a/test/simple/test-fs-chmod.js b/test/simple/test-fs-chmod.js index f8c4d71..732f29b 100644 --- a/test/simple/test-fs-chmod.js +++ b/test/simple/test-fs-chmod.js @@ -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); diff --git a/test/simple/test-fs-read-buffer.js b/test/simple/test-fs-read-buffer.js index 5a18177..7d4ebbf 100644 --- a/test/simple/test-fs-read-buffer.js +++ b/test/simple/test-fs-read-buffer.js @@ -22,4 +22,4 @@ assert.equal(r, expected.length); process.addListener('exit', function() { assert.equal(readCalled, 1); -}); \ No newline at end of file +}); diff --git a/test/simple/test-fs-read.js b/test/simple/test-fs-read.js index 7f9bf48..bb23bc9 100644 --- a/test/simple/test-fs-read.js +++ b/test/simple/test-fs-read.js @@ -20,4 +20,4 @@ assert.equal(r[1], expected.length); process.addListener('exit', function() { assert.equal(readCalled, 1); -}); \ No newline at end of file +}); diff --git a/test/simple/test-fs-readfile-empty.js b/test/simple/test-fs-readfile-empty.js index 8073fb5..fec0cd7 100644 --- a/test/simple/test-fs-readfile-empty.js +++ b/test/simple/test-fs-readfile-empty.js @@ -7,4 +7,4 @@ var fs.readFile(fn, function(err, data) { assert.ok(data); -}); \ No newline at end of file +}); diff --git a/test/simple/test-fs-realpath.js b/test/simple/test-fs-realpath.js index 2bf444e..6a6a70f 100644 --- a/test/simple/test-fs-realpath.js +++ b/test/simple/test-fs-realpath.js @@ -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(); diff --git a/test/simple/test-fs-stat.js b/test/simple/test-fs-stat.js index eb19251..c063eb9 100644 --- a/test/simple/test-fs-stat.js +++ b/test/simple/test-fs-stat.js @@ -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); diff --git a/test/simple/test-fs-symlink.js b/test/simple/test-fs-symlink.js index f7363eb..b35d3fe 100644 --- a/test/simple/test-fs-symlink.js +++ b/test/simple/test-fs-symlink.js @@ -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); diff --git a/test/simple/test-fs-write.js b/test/simple/test-fs-write.js index 24a8b8c..3c7004d 100644 --- a/test/simple/test-fs-write.js +++ b/test/simple/test-fs-write.js @@ -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); }); }); diff --git a/test/simple/test-http-1.0.js b/test/simple/test-http-1.0.js index 534a408..c284135 100644 --- a/test/simple/test-http-1.0.js +++ b/test/simple/test-http-1.0.js @@ -24,7 +24,7 @@ c.addListener("connect", function () { }); c.addListener("data", function (chunk) { - puts(chunk); + console.log(chunk); server_response += chunk; }); diff --git a/test/simple/test-http-304.js b/test/simple/test-http-304.js index e71befc..1d986c1 100644 --- a/test/simple/test-http-304.js +++ b/test/simple/test-http-304.js @@ -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+'/') diff --git a/test/simple/test-http-cat.js b/test/simple/test-http-cat.js index 69787eb..5bb778d 100644 --- a/test/simple/test-http-cat.js +++ b/test/simple/test-http-cat.js @@ -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); }); diff --git a/test/simple/test-http-chunked.js b/test/simple/test-http-chunked.js index b1168eb..14f0265 100644 --- a/test/simple/test-http-chunked.js +++ b/test/simple/test-http-chunked.js @@ -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(); }) diff --git a/test/simple/test-http-client-upload.js b/test/simple/test-http-client-upload.js index 82fd890..8627cdc 100644 --- a/test/simple/test-http-client-upload.js +++ b/test/simple/test-http-client-upload.js @@ -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; diff --git a/test/simple/test-http-exceptions.js b/test/simple/test-http-exceptions.js index b373f8f..71bd091 100644 --- a/test/simple/test-http-exceptions.js +++ b/test/simple/test-http-exceptions.js @@ -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); } diff --git a/test/simple/test-http-full-response.js b/test/simple/test-http-full-response.js index 6898805..095ee3d 100644 --- a/test/simple/test-http-full-response.js +++ b/test/simple/test-http-full-response.js @@ -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(); }); }); diff --git a/test/simple/test-http-malformed-request.js b/test/simple/test-http-malformed-request.js index e93fba9..7145527 100644 --- a/test/simple/test-http-malformed-request.js +++ b/test/simple/test-http-malformed-request.js @@ -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"); diff --git a/test/simple/test-http-parser.js b/test/simple/test-http-parser.js index e524cd0..159aefd 100644 --- a/test/simple/test-http-parser.js +++ b/test/simple/test-http-parser.js @@ -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++; }; diff --git a/test/simple/test-http-set-timeout.js b/test/simple/test-http-set-timeout.js index fdf5918..d15044d 100644 --- a/test/simple/test-http-set-timeout.js +++ b/test/simple/test-http-set-timeout.js @@ -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)'); }); }); diff --git a/test/simple/test-http-tls.js b/test/simple/test-http-tls.js index 11845da..db4ce90 100644 --- a/test/simple/test-http-tls.js +++ b/test/simple/test-http-tls.js @@ -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"}); diff --git a/test/simple/test-http-wget.js b/test/simple/test-http-wget.js index 47e215e..98ea43f 100644 --- a/test/simple/test-http-wget.js +++ b/test/simple/test-http-wget.js @@ -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(); }); diff --git a/test/simple/test-http-write-empty-string.js b/test/simple/test-http-write-empty-string.js index 2ccce59..3b430c8 100644 --- a/test/simple/test-http-write-empty-string.js +++ b/test/simple/test-http-write-empty-string.js @@ -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'); diff --git a/test/simple/test-memory-usage.js b/test/simple/test-memory-usage.js index 8efe0f5..0d45546 100644 --- a/test/simple/test-memory-usage.js +++ b/test/simple/test-memory-usage.js @@ -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); diff --git a/test/simple/test-mkdir-rmdir.js b/test/simple/test-mkdir-rmdir.js index 1464370..1a31bf3 100644 --- a/test/simple/test-mkdir-rmdir.js +++ b/test/simple/test-mkdir-rmdir.js @@ -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"); }); diff --git a/test/simple/test-module-loading.js b/test/simple/test-module-loading.js index 460c794..220c3d1 100644 --- a/test/simple/test-module-loading.js +++ b/test/simple/test-module-loading.js @@ -113,5 +113,5 @@ process.addListener("exit", function () { assert.equal(true, errorThrownAsync); - puts("exit"); + console.log("exit"); }); diff --git a/test/simple/test-net-binary.js b/test/simple/test-net-binary.js index 9dc347a..ad6f4f0 100644 --- a/test/simple/test-net-binary.js +++ b/test/simple/test-net-binary.js @@ -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); }); diff --git a/test/simple/test-net-pingpong.js b/test/simple/test-net-pingpong.js index d715e2c..cc8a0c2 100644 --- a/test/simple/test-net-pingpong.js +++ b/test/simple/test-net-pingpong.js @@ -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'); }); diff --git a/test/simple/test-net-reconnect.js b/test/simple/test-net-reconnect.js index 9b297a7..b5be64d 100644 --- a/test/simple/test-net-reconnect.js +++ b/test/simple/test-net-reconnect.js @@ -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 diff --git a/test/simple/test-net-tls.js b/test/simple/test-net-tls.js index a5633d0..b6c1d11 100644 --- a/test/simple/test-net-tls.js +++ b/test/simple/test-net-tls.js @@ -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(); } diff --git a/test/simple/test-next-tick-ordering.js b/test/simple/test-next-tick-ordering.js index ee41f05..b08e227 100644 --- a/test/simple/test-next-tick-ordering.js +++ b/test/simple/test-next-tick-ordering.js @@ -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 () { diff --git a/test/simple/test-readdir.js b/test/simple/test-readdir.js index c90fe37..b1881fc 100644 --- a/test/simple/test-readdir.js +++ b/test/simple/test-readdir.js @@ -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"); }); diff --git a/test/simple/test-regression-object-prototype.js b/test/simple/test-regression-object-prototype.js index 7c6f451..913e120 100644 --- a/test/simple/test-regression-object-prototype.js +++ b/test/simple/test-regression-object-prototype.js @@ -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'); diff --git a/test/simple/test-signal-handler.js b/test/simple/test-signal-handler.js index 5e772d1..50d37c0 100644 --- a/test/simple/test-signal-handler.js +++ b/test/simple/test-signal-handler.js @@ -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"); diff --git a/test/simple/test-signal-unregister.js b/test/simple/test-signal-unregister.js index 29ce09d..ee4fcf8 100644 --- a/test/simple/test-signal-unregister.js +++ b/test/simple/test-signal-unregister.js @@ -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); diff --git a/test/simple/test-stdin-from-file.js b/test/simple/test-stdin-from-file.js index 0c7e8f7..7e4a445 100644 --- a/test/simple/test-stdin-from-file.js +++ b/test/simple/test-stdin-from-file.js @@ -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); }); diff --git a/test/simple/test-stdout-to-file.js b/test/simple/test-stdout-to-file.js index 5c611bf..3df3bfa 100644 --- a/test/simple/test-stdout-to-file.js +++ b/test/simple/test-stdout-to-file.js @@ -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; }); }); diff --git a/test/simple/test-string-decoder.js b/test/simple/test-string-decoder.js index fd52675..1f61d5c 100644 --- a/test/simple/test-string-decoder.js +++ b/test/simple/test-string-decoder.js @@ -59,5 +59,5 @@ for (var j = 2; j < buffer.length; j++) { print("."); } } -puts(" crayon!"); +console.log(" crayon!"); diff --git a/test/simple/test-utf8-scripts.js b/test/simple/test-utf8-scripts.js index a3b46e1..6861c7e 100644 --- a/test/simple/test-utf8-scripts.js +++ b/test/simple/test-utf8-scripts.js @@ -2,7 +2,7 @@ require("../common"); // üäö -puts("Σὲ γνωρίζω ἀπὸ τὴν κόψη"); +console.log("Σὲ γνωρίζω ἀπὸ τὴν κόψη"); assert.equal(true, /Hellö Wörld/.test("Hellö Wörld") ); -- 2.7.4