diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-03-06 12:54:12 +0100 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2019-03-08 13:57:38 +0100 |
commit | b05fd4baa87886674721101eaf38b75716037891 (patch) | |
tree | 944d9db74ba3b14a9d74f3be081cc1351c338bb9 /lib/_stream_readable.js | |
parent | 687f30467b67db9f39334cd19faa484c20a4ab06 (diff) | |
download | android-node-v8-b05fd4baa87886674721101eaf38b75716037891.tar.gz android-node-v8-b05fd4baa87886674721101eaf38b75716037891.tar.bz2 android-node-v8-b05fd4baa87886674721101eaf38b75716037891.zip |
lib: explicitly initialize debuglog during bootstrap
This patch splits the implementation of util.debuglog into a
separate file and explicitly initialize it during pre-execution
since the initialization depends on environment variables.
Also delays the call to `debuglog` in modules that are loaded during
bootstrap to make sure we only access the environment variable
during pre-execution.
PR-URL: https://github.com/nodejs/node/pull/26468
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/_stream_readable.js')
-rw-r--r-- | lib/_stream_readable.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 85d1fb0c33..957f232b63 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -27,8 +27,15 @@ Readable.ReadableState = ReadableState; const EE = require('events'); const Stream = require('stream'); const { Buffer } = require('buffer'); -const util = require('util'); -const debug = util.debuglog('stream'); + +let debuglog; +function debug(...args) { + if (!debuglog) { + debuglog = require('internal/util/debuglog').debuglog('stream'); + } + debuglog(...args); +} + const BufferList = require('internal/streams/buffer_list'); const destroyImpl = require('internal/streams/destroy'); const { getHighWaterMark } = require('internal/streams/state'); |