Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-04-17 18:45:53 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-19 19:30:38 +0300
commit2e4ceb5747b0e5d1bccd79837de7731c4030dc48 (patch)
tree0088f5fb0fb5b4dd1eb80d7186f889dee4864f1f /lib/internal/worker
parent49ee0100059ef252c3dd2372f9b3807a60cd80f8 (diff)
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>
Diffstat (limited to 'lib/internal/worker')
-rw-r--r--lib/internal/worker/io.js9
1 files changed, 1 insertions, 8 deletions
diff --git a/lib/internal/worker/io.js b/lib/internal/worker/io.js
index 04f8f9ad597..8b7aedd39d0 100644
--- a/lib/internal/worker/io.js
+++ b/lib/internal/worker/io.js
@@ -21,14 +21,7 @@ const {
const { Readable, Writable } = require('stream');
const EventEmitter = require('events');
const { inspect } = require('internal/util/inspect');
-
-let debuglog;
-function debug(...args) {
- if (!debuglog) {
- debuglog = require('internal/util/debuglog').debuglog('worker');
- }
- debuglog(...args);
-}
+const debug = require('internal/util/debuglog').debuglog('worker');
const kIncrementsPortRef = Symbol('kIncrementsPortRef');
const kName = Symbol('kName');