Skip to content

Commit eaa9d15

Browse files
committed
refactor(cli): change cli name to client logging
1 parent 01a929e commit eaa9d15

File tree

8 files changed

+23
-16
lines changed

8 files changed

+23
-16
lines changed

bin/cli-flags.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ module.exports = {
6565
describe: 'Open default browser with the specified page',
6666
},
6767
{
68-
name: 'client-log-level',
68+
name: 'client-logging',
6969
type: String,
7070
group: DISPLAY_GROUP,
7171
defaultValue: 'info',

bin/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const options = {
7373
group: DISPLAY_GROUP,
7474
describe: 'Enables/Disables colors on the console',
7575
},
76-
'client-log-level': {
76+
'client-logging': {
7777
type: 'string',
7878
group: DISPLAY_GROUP,
7979
default: 'info',

client-src/default/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const onSocketMessage = {
6767
}
6868
sendMessage('StillOk');
6969
},
70-
'log-level': function logLevel(level) {
70+
logging: function logging(level) {
7171
// this is needed because the HMR logger operate separately from
7272
// dev server logger
7373
const hotCtx = require.context('webpack/hot', false, /^\.\/log$/);

lib/Server.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,12 @@ class Server {
634634
}
635635
});
636636

637-
if (this.options.clientLogLevel) {
638-
this.sockWrite([connection], 'log-level', this.options.clientLogLevel);
637+
if (this.options.clientOptions.logging) {
638+
this.sockWrite(
639+
[connection],
640+
'logging',
641+
this.options.clientOptions.logging
642+
);
639643
}
640644

641645
if (this.options.hot === true || this.options.hot === 'only') {

lib/options.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
"bonjour": {
1111
"type": "boolean"
1212
},
13-
"clientLogLevel": {
14-
"enum": ["none", "error", "warn", "info", "log", "verbose"]
15-
},
1613
"clientOptions": {
1714
"type": "object",
1815
"properties": {
@@ -34,6 +31,9 @@
3431
"type": "null"
3532
}
3633
]
34+
},
35+
"logging": {
36+
"enum": ["none", "error", "warn", "info", "log", "verbose"]
3737
}
3838
},
3939
"additionalProperties": false
@@ -390,7 +390,6 @@
390390
"properties": {
391391
"allowedHosts": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserverallowedhosts)",
392392
"bonjour": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverbonjour)",
393-
"clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'none', 'silent', 'info', 'debug', 'trace', 'error', 'warning', 'warn' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
394393
"clientOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverclientoptions)",
395394
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
396395
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",

lib/utils/createConfig.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ function createConfig(config, argv, { port }) {
8080
options.hot = hasHotOnly ? 'only' : argv.hot;
8181
}
8282

83-
// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
84-
// We should prefer CLI arg under config, now we always prefer `clientLogLevel` from `devServer`
85-
if (!options.clientLogLevel && argv.clientLogLevel) {
86-
options.clientLogLevel = argv.clientLogLevel;
83+
if (argv.clientLogging) {
84+
if (options.clientOptions) {
85+
options.clientOptions.logging = argv.clientLogging;
86+
} else {
87+
options.clientOptions = {
88+
logging: argv.clientLogging,
89+
};
90+
}
8791
}
8892

8993
if (argv.contentBase) {

test/client/__snapshots__/index.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Array [
9494
"hot": [Function],
9595
"invalid": [Function],
9696
"liveReload": [Function],
97-
"log-level": [Function],
97+
"logging": [Function],
9898
"ok": [Function],
9999
"overlay": [Function],
100100
"progress": [Function],

test/client/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ describe('index', () => {
110110
});
111111

112112
// TODO: need to mock require.context
113-
test.skip("should run onSocketMessage['log-level']", () => {
114-
onSocketMessage['log-level']();
113+
test.skip("should run onSocketMessage['logging']", () => {
114+
onSocketMessage.logging();
115115
});
116116

117117
test("should run onSocketMessage.progress and onSocketMessage['progress-update']", () => {

0 commit comments

Comments
 (0)