mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
util: access process states lazily in debuglog
`debuglog()` depends on `process.pid` and `process.env.NODE_DEBUG`, so it needs to be called lazily in top scopes of internal modules that may be loaded before these run time states are allowed to be accessed. This patch makes its implementation lazy by default, the process states are only accessed when the returned debug function is called for the first time. PR-URL: https://github.com/nodejs/node/pull/27281 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
This commit is contained in:
parent
49ee010005
commit
2e4ceb5747
9 changed files with 25 additions and 51 deletions
|
@ -50,14 +50,7 @@ const {
|
|||
deprecate
|
||||
} = require('internal/util');
|
||||
const { ERR_INVALID_CALLBACK } = require('internal/errors').codes;
|
||||
|
||||
let debuglog;
|
||||
function debug(...args) {
|
||||
if (!debuglog) {
|
||||
debuglog = require('internal/util/debuglog').debuglog('timer');
|
||||
}
|
||||
debuglog(...args);
|
||||
}
|
||||
const debug = require('internal/util/debuglog').debuglog('timer');
|
||||
|
||||
const {
|
||||
destroyHooksExist,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue