From a728a3ff0e1611fdc4a677524aafead97a8f726e Mon Sep 17 00:00:00 2001 From: daemon1024 Date: Mon, 6 Apr 2020 22:39:29 +0530 Subject: [PATCH] test: replace console.log/error() with debuglog PR-URL: https://github.com/nodejs/node/pull/32692 Fixes: https://github.com/nodejs/node/issues/32678 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Zeyu Yang Reviewed-By: Trivikram Kamat --- test/parallel/test-domain-http-server.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-domain-http-server.js b/test/parallel/test-domain-http-server.js index 5b1ef68106cfda..6168566334a11d 100644 --- a/test/parallel/test-domain-http-server.js +++ b/test/parallel/test-domain-http-server.js @@ -24,6 +24,7 @@ require('../common'); const domain = require('domain'); const http = require('http'); const assert = require('assert'); +const debug = require('util').debuglog('test'); const objects = { foo: 'bar', baz: {}, num: 42, arr: [1, 2, 3] }; objects.baz.asdf = objects; @@ -39,7 +40,7 @@ const server = http.createServer(function(req, res) { dom.on('error', function(er) { serverCaught++; - console.log('horray! got a server error', er); + debug('horray! got a server error', er); // Try to send a 500. If that fails, oh well. res.writeHead(500, { 'content-type': 'text/plain' }); res.end(er.stack || er.message || 'Unknown error'); @@ -62,7 +63,7 @@ server.listen(0, next); function next() { const port = this.address().port; - console.log(`listening on localhost:${port}`); + debug(`listening on localhost:${port}`); let requests = 0; let responses = 0; @@ -79,7 +80,7 @@ function next() { const dom = domain.create(); dom.on('error', function(er) { clientCaught++; - console.log('client error', er); + debug('client error', er); req.socket.destroy(); }); @@ -87,9 +88,9 @@ function next() { dom.add(req); req.on('response', function(res) { responses++; - console.error(`requests=${requests} responses=${responses}`); + debug(`requests=${requests} responses=${responses}`); if (responses === requests) { - console.error('done, closing server'); + debug('done, closing server'); // no more coming. server.close(); } @@ -100,9 +101,9 @@ function next() { d += c; }); res.on('end', function() { - console.error('trying to parse json', d); + debug('trying to parse json', d); d = JSON.parse(d); - console.log('json!', d); + debug('json!', d); }); }); } @@ -111,5 +112,5 @@ function next() { process.on('exit', function() { assert.strictEqual(serverCaught, 2); assert.strictEqual(clientCaught, 2); - console.log('ok'); + debug('ok'); });