summaryrefslogtreecommitdiff
path: root/runtime/js/06_util.js
diff options
context:
space:
mode:
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 };