Skip to content

Commit 9f16b7f

Browse files
mscdexaddaleax
authored andcommitted
lib: improve debuglog() performance
PR-URL: #32260 Reviewed-By: James M Snell <[email protected]>
1 parent 3598056 commit 9f16b7f

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
@@ -30,7 +30,9 @@ const{
3030

3131
constnet=require('net');
3232
constEventEmitter=require('events');
33-
constdebug=require('internal/util/debuglog').debuglog('http');
33+
letdebug=require('internal/util/debuglog').debuglog('http',(fn)=>{
34+
debug=fn;
35+
});
3436
const{ async_id_symbol }=require('internal/async_hooks').symbols;
3537
constkOnKeylog=Symbol('onkeylog');
3638
// New Agent code.

‎lib/_http_common.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ const{
4242
readStop
4343
}=incoming;
4444

45-
constdebug=require('internal/util/debuglog').debuglog('http');
45+
letdebug=require('internal/util/debuglog').debuglog('http',(fn)=>{
46+
debug=fn;
47+
});
4648

4749
constkIncomingMessage=Symbol('IncomingMessage');
4850
constkOnHeaders=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
constStream=require('stream');
4040
const{ Buffer }=require('buffer');
4141

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

‎lib/_tls_wrap.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ const tls = require('tls');
4545
constcommon=require('_tls_common');
4646
constJSStreamSocket=require('internal/js_stream_socket');
4747
const{ Buffer }=require('buffer');
48-
constdebug=require('internal/util/debuglog').debuglog('tls');
48+
letdebug=require('internal/util/debuglog').debuglog('tls',(fn)=>{
49+
debug=fn;
50+
});
4951
const{TCP,constants: TCPConstants}=internalBinding('tcp_wrap');
5052
consttls_wrap=internalBinding('tls_wrap');
5153
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-
constdebug=require('internal/util/debuglog').debuglog('child_process');
40+
letdebug=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-
constdebug=require('internal/util/debuglog').debuglog('https');
40+
letdebug=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-
constdebug=require('internal/util/debuglog').debuglog('http2');
155+
letdebug=require('internal/util/debuglog').debuglog('http2',(fn)=>{
156+
debug=fn;
157+
});
156158
const{ getOptionValue }=require('internal/options');
157159

158160
// TODO(addaleax): See if this can be made more efficient by figuring out

‎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
constuv=internalBinding('uv');
12-
constdebug=require('internal/util/debuglog').debuglog('stream_socket');
12+
letdebug=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
constpublicWorker=require('worker_threads');
52-
constdebug=require('internal/util/debuglog').debuglog('worker');
52+
letdebug=require('internal/util/debuglog').debuglog('worker',(fn)=>{
53+
debug=fn;
54+
});
5355

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

‎lib/internal/modules/cjs/helpers.js‎

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

18-
constdebug=require('internal/util/debuglog').debuglog('module');
18+
letdebug=require('internal/util/debuglog').debuglog('module',(fn)=>{
19+
debug=fn;
20+
});
1921

2022
functionloadNativeModule(filename,request){
2123
constmod=NativeModule.map.get(filename);

0 commit comments

Comments
(0)