summaryrefslogtreecommitdiff
path: root/runtime/js/06_util.js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-11-12 20:52:59 -0800
committerGitHub <noreply@github.com>2023-11-13 04:52:59 +0000
commit1ef617e8f3d48098e69e222b6eb6fe981aeca1c3 (patch)
tree8ab4fab5b5b248d51575e874f240c16fba4ae268 /runtime/js/06_util.js
parent39223f709bcb86069f3aa8eab7a4be80304128e6 (diff)
perf: lazy bootstrap options - first pass (#21164)
Move most runtime options to be lazily loaded. Constant options will be covered in a different PR. Towards https://github.com/denoland/deno/issues/21133
Diffstat (limited to 'runtime/js/06_util.js')
-rw-r--r--runtime/js/06_util.js26
1 files changed, 10 insertions, 16 deletions
diff --git a/runtime/js/06_util.js b/runtime/js/06_util.js
index 971957b7e..c9fd4befe 100644
--- a/runtime/js/06_util.js
+++ b/runtime/js/06_util.js
@@ -1,5 +1,7 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+const core = globalThis.Deno.core;
+const ops = core.ops;
const primordials = globalThis.__bootstrap.primordials;
const {
Promise,
@@ -14,18 +16,18 @@ const LogLevel = {
Debug: 4,
};
-let logLevel = 3;
-let logSource = "JS";
+const logSource = "JS";
-function setLogLevel(level, source) {
- logLevel = level;
- if (source) {
- logSource = source;
+let logLevel_ = null;
+function logLevel() {
+ if (logLevel_ === null) {
+ logLevel_ = ops.op_bootstrap_log_level() || 3;
}
+ return logLevel_;
}
function log(...args) {
- if (logLevel >= LogLevel.Debug) {
+ if (logLevel() >= LogLevel.Debug) {
// if we destructure `console` off `globalThis` too early, we don't bind to
// the right console, therefore we don't log anything out.
globalThis.console.error(
@@ -83,12 +85,4 @@ function getterOnly(getter) {
};
}
-export {
- createResolvable,
- getterOnly,
- log,
- nonEnumerable,
- readOnly,
- setLogLevel,
- writable,
-};
+export { createResolvable, getterOnly, log, nonEnumerable, readOnly, writable };