http: optimize debug function correctly · nodejs/node@d86aca9

4 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -47,7 +47,6 @@ const assert = require('internal/assert');

4747

const { once } = require('internal/util');

4848

const {

4949

_checkIsHttpToken: checkIsHttpToken,

50-

debug,

5150

freeParser,

5251

parsers,

5352

HTTPParser,

@@ -79,6 +78,10 @@ const {

7978
8079

const { addAbortSignal, finished } = require('stream');

8180
81+

let debug = require('internal/util/debuglog').debuglog('http', (fn) => {

82+

debug = fn;

83+

});

84+
8285

const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/;

8386

const kError = Symbol('kError');

8487
Original file line numberDiff line numberDiff line change

@@ -269,7 +269,6 @@ module.exports = {

269269

chunkExpression: /(?:^|\W)chunked(?:$|\W)/i,

270270

continueExpression: /(?:^|\W)100-continue(?:$|\W)/i,

271271

CRLF: '\r\n',

272-

debug,

273272

freeParser,

274273

methods,

275274

parsers,

Original file line numberDiff line numberDiff line change

@@ -79,8 +79,12 @@ const {

7979

const { validateString } = require('internal/validators');

8080

const { isUint8Array } = require('internal/util/types');

8181
82+

let debug = require('internal/util/debuglog').debuglog('http', (fn) => {

83+

debug = fn;

84+

});

85+
8286

const HIGH_WATER_MARK = getDefaultHighWaterMark();

83-

const { CRLF, debug } = common;

87+

const { CRLF } = common;

8488
8589

const kCorked = Symbol('corked');

8690
Original file line numberDiff line numberDiff line change

@@ -45,7 +45,6 @@ const assert = require('internal/assert');

4545

const {

4646

parsers,

4747

freeParser,

48-

debug,

4948

CRLF,

5049

continueExpression,

5150

chunkExpression,

@@ -93,6 +92,10 @@ const { observerCounts, constants } = internalBinding('performance');

9392

const { setTimeout, clearTimeout } = require('timers');

9493

const { NODE_PERFORMANCE_ENTRY_TYPE_HTTP } = constants;

9594
95+

let debug = require('internal/util/debuglog').debuglog('http', (fn) => {

96+

debug = fn;

97+

});

98+
9699

const dc = require('diagnostics_channel');

97100

const onRequestStartChannel = dc.channel('http.server.request.start');

98101

const onResponseFinishChannel = dc.channel('http.server.response.finish');