Skip to content

Commit b7690da

Browse files
mscdexcodebytere
authored andcommitted
lib: improve debuglog() performance
PR-URL: #32260 Reviewed-By: James M Snell <[email protected]>
1 parent 24105a7 commit b7690da

28 files changed

+101
-40
lines changed

lib/_http_agent.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ const {
3131

3232
const net = require('net');
3333
const EventEmitter = require('events');
34-
const debug = require('internal/util/debuglog').debuglog('http');
34+
let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
35+
debug = fn;
36+
});
3537
const { async_id_symbol } = require('internal/async_hooks').symbols;
3638
const {
3739
codes: {

lib/_http_common.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ const {
3939
readStop
4040
} = incoming;
4141

42-
const debug = require('internal/util/debuglog').debuglog('http');
42+
let debug = require('internal/util/debuglog').debuglog('http', (fn) => {
43+
debug = fn;
44+
});
4345

4446
const kIncomingMessage = Symbol('IncomingMessage');
4547
const kOnHeaders = HTTPParser.kOnHeaders | 0;

lib/_stream_readable.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ const EE = require('events');
3939
const Stream = require('stream');
4040
const { Buffer } = require('buffer');
4141

42-
const debug = require('internal/util/debuglog').debuglog('stream');
42+
let debug = require('internal/util/debuglog').debuglog('stream', (fn) => {
43+
debug = fn;
44+
});
4345
const BufferList = require('internal/streams/buffer_list');
4446
const destroyImpl = require('internal/streams/destroy');
4547
const {

lib/_tls_wrap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ const tls = require('tls');
4646
const common = require('_tls_common');
4747
const JSStreamSocket = require('internal/js_stream_socket');
4848
const { Buffer } = require('buffer');
49-
const debug = require('internal/util/debuglog').debuglog('tls');
49+
let debug = require('internal/util/debuglog').debuglog('tls', (fn) => {
50+
debug = fn;
51+
});
5052
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
5153
const tls_wrap = internalBinding('tls_wrap');
5254
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');

lib/child_process.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ const {
3737
getSystemErrorName
3838
} = require('internal/util');
3939
const { isArrayBufferView } = require('internal/util/types');
40-
const debug = require('internal/util/debuglog').debuglog('child_process');
40+
let debug = require('internal/util/debuglog').debuglog(
41+
'child_process',
42+
(fn) => {
43+
debug = fn;
44+
}
45+
);
4146
const { Buffer } = require('buffer');
4247
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
4348
const {

lib/https.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ const {
3737
kServerResponse
3838
} = require('_http_server');
3939
const { ClientRequest } = require('_http_client');
40-
const debug = require('internal/util/debuglog').debuglog('https');
40+
let debug = require('internal/util/debuglog').debuglog('https', (fn) => {
41+
debug = fn;
42+
});
4143
const { URL, urlToOptions, searchParamsSymbol } = require('internal/url');
4244
const { IncomingMessage, ServerResponse } = require('http');
4345
const { kIncomingMessage } = require('_http_common');

lib/internal/http2/core.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ const { UV_EOF } = internalBinding('uv');
152152

153153
const { StreamPipe } = internalBinding('stream_pipe');
154154
const { _connectionListener: httpConnectionListener } = http;
155-
const debug = require('internal/util/debuglog').debuglog('http2');
155+
let debug = require('internal/util/debuglog').debuglog('http2', (fn) => {
156+
debug = fn;
157+
});
156158

157159
// TODO(addaleax): See if this can be made more efficient by figuring out
158160
// whether debugging is enabled before we perform any further steps. Currently,

lib/internal/js_stream_socket.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ const assert = require('internal/assert');
99
const { Socket } = require('net');
1010
const { JSStream } = internalBinding('js_stream');
1111
const uv = internalBinding('uv');
12-
const debug = require('internal/util/debuglog').debuglog('stream_socket');
12+
let debug = require('internal/util/debuglog').debuglog(
13+
'stream_socket',
14+
(fn) => {
15+
debug = fn;
16+
}
17+
);
1318
const { owner_symbol } = require('internal/async_hooks').symbols;
1419
const { ERR_STREAM_WRAP } = require('internal/errors').codes;
1520

lib/internal/main/worker_thread.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ const {
4949
} = require('internal/process/execution');
5050

5151
const publicWorker = require('worker_threads');
52-
const debug = require('internal/util/debuglog').debuglog('worker');
52+
let debug = require('internal/util/debuglog').debuglog('worker', (fn) => {
53+
debug = fn;
54+
});
5355

5456
const assert = require('internal/assert');
5557

lib/internal/modules/cjs/helpers.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const path = require('path');
1616
const { pathToFileURL, fileURLToPath } = require('internal/url');
1717
const { URL } = require('url');
1818

19-
const debug = require('internal/util/debuglog').debuglog('module');
19+
let debug = require('internal/util/debuglog').debuglog('module', (fn) => {
20+
debug = fn;
21+
});
2022

2123
function loadNativeModule(filename, request) {
2224
const mod = NativeModule.map.get(filename);

0 commit comments

Comments
 (0)