Skip to content

Commit 659b04c

Browse files
committed
add experimental logger module support
1 parent 108a2c4 commit 659b04c

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

lib/internal/bootstrap/realm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ const schemelessBlockList = new SafeSet([
127127
'sea',
128128
'sqlite',
129129
'quic',
130+
'logger',
130131
'test',
131132
'test/reporters',
132133
]);
133134
// Modules that will only be enabled at run time.
134-
const experimentalModuleList = new SafeSet(['sqlite', 'quic']);
135+
const experimentalModuleList = new SafeSet(['sqlite', 'quic', 'logger']);
135136

136137
// Set up process.binding() and process._linkedBinding().
137138
{

lib/internal/process/pre_execution.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ function prepareExecution(options) {
115115
setupNavigator();
116116
setupWarningHandler();
117117
setupSQLite();
118+
setupLogger();
118119
setupQuic();
119120
setupWebStorage();
120121
setupWebsocket();
@@ -380,6 +381,15 @@ function setupSQLite() {
380381
BuiltinModule.allowRequireByUsers('sqlite');
381382
}
382383

384+
function setupLogger() {
385+
if (!getOptionValue('--experimental-logger')) {
386+
return;
387+
}
388+
389+
const { BuiltinModule } = require('internal/bootstrap/realm');
390+
BuiltinModule.allowRequireByUsers('logger');
391+
}
392+
383393
function initializeConfigFileSupport() {
384394
if (getOptionValue('--experimental-default-config-file') ||
385395
getOptionValue('--experimental-config-file')) {

lib/logger.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const {
1111

1212
const { isNativeError } = require('internal/util/types');
1313

14-
1514
const {
1615
codes: {
1716
ERR_INVALID_ARG_TYPE,
@@ -28,7 +27,8 @@ const {
2827

2928
const Utf8Stream = require('internal/streams/fast-utf8-stream');
3029
const diagnosticsChannel = require('diagnostics_channel');
31-
const { kEmptyObject } = require('internal/util');
30+
const { emitExperimentalWarning, kEmptyObject } = require('internal/util');
31+
emitExperimentalWarning('Logger');
3232
const stdSerializers = require('internal/logger/serializers');
3333

3434
// Create channels for each log level

src/node_options.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
573573
&EnvironmentOptions::experimental_sqlite,
574574
kAllowedInEnvvar,
575575
true);
576+
AddOption("--experimental-logger",
577+
"experimental node:logger module",
578+
&EnvironmentOptions::experimental_logger,
579+
kAllowedInEnvvar);
576580
AddOption("--experimental-quic",
577581
#ifndef OPENSSL_NO_QUIC
578582
"experimental QUIC support",

src/node_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class EnvironmentOptions : public Options {
127127
bool experimental_fetch = true;
128128
bool experimental_websocket = true;
129129
bool experimental_sqlite = true;
130+
bool experimental_logger = false;
130131
bool webstorage = HAVE_SQLITE;
131132
#ifndef OPENSSL_NO_QUIC
132133
bool experimental_quic = false;

0 commit comments

Comments
 (0)