Skip to content

Commit 7f52bbf

Browse files
gabemeolahiroppy
authored andcommittedApr 27, 2019
fix: update clientLogLevel to match docs and error (#1825)
1 parent b5bc05c commit 7f52bbf

File tree

5 files changed

+43
-17
lines changed

5 files changed

+43
-17
lines changed
 

‎bin/options.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ const options = {
8585
type: 'string',
8686
group: DISPLAY_GROUP,
8787
default: 'info',
88-
describe: 'Log level in the browser (info, warning, error or none)',
88+
describe:
89+
'Log level in the browser (trace, debug, info, warn, error or silent)',
8990
},
9091
https: {
9192
type: 'boolean',

‎client-src/default/index.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ let useErrorOverlay = false;
5454
let useProgress = false;
5555

5656
const INFO = 'info';
57-
const WARNING = 'warning';
57+
const WARN = 'warn';
5858
const ERROR = 'error';
59-
const NONE = 'none';
59+
const DEBUG = 'debug';
60+
const TRACE = 'trace';
61+
const SILENT = 'silent';
6062

6163
// Set the default log level
6264
log.setDefaultLevel(INFO);
@@ -108,14 +110,13 @@ const onSocketMsg = {
108110
}
109111
switch (level) {
110112
case INFO:
113+
case WARN:
114+
case DEBUG:
115+
case TRACE:
111116
case ERROR:
112117
log.setLevel(level);
113118
break;
114-
case WARNING:
115-
// loglevel's warning name is different from webpack's
116-
log.setLevel('warn');
117-
break;
118-
case NONE:
119+
case SILENT:
119120
log.disableAll();
120121
break;
121122
default:

‎lib/options.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
]
3838
},
3939
"clientLogLevel": {
40-
"enum": ["none", "info", "error", "warning"]
40+
"enum": ["info", "warn", "error", "debug", "trace", "silent"]
4141
},
4242
"compress": {
4343
"type": "boolean"
@@ -354,7 +354,7 @@
354354
"bonjour": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverbonjour)",
355355
"ca": "should be {String|Buffer}",
356356
"cert": "should be {String|Buffer}",
357-
"clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'none', 'info', 'error', 'warning' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
357+
"clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'info', 'warn', 'error', 'debug', 'trace', 'silent' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
358358
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
359359
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
360360
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)",

‎test/options/__snapshots__/options.test.js.snap

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Object {
1010
"cert": "should be {String|Buffer}",
1111
"clientLogLevel": "should be {String} and equal to one of the allowed values
1212
13-
[ 'none', 'info', 'error', 'warning' ]
13+
[ 'info', 'warn', 'error', 'debug', 'trace', 'silent' ]
1414
1515
(https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
1616
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
@@ -109,10 +109,12 @@ Object {
109109
},
110110
"clientLogLevel": Object {
111111
"enum": Array [
112-
"none",
113112
"info",
113+
"warn",
114114
"error",
115-
"warning",
115+
"debug",
116+
"trace",
117+
"silent",
116118
],
117119
},
118120
"compress": Object {

‎test/options/clientLogLevel.test.js

+26-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ describe('Validation', () => {
2727
}
2828
});
2929

30-
it('should allow clientLogLevel to be a "none"', () => {
30+
it('should allow clientLogLevel to be a "silent"', () => {
3131
let error = null;
3232
try {
33-
const clientLogLevel = 'none';
33+
const clientLogLevel = 'silent';
3434
server = new Server(compiler, { clientLogLevel });
3535
} catch (err) {
3636
error = err;
@@ -60,10 +60,32 @@ describe('Validation', () => {
6060
expect(error).toBe(null);
6161
});
6262

63-
it('should allow clientLogLevel to be a "warning"', () => {
63+
it('should allow clientLogLevel to be a "warn"', () => {
6464
let error = null;
6565
try {
66-
const clientLogLevel = 'warning';
66+
const clientLogLevel = 'warn';
67+
server = new Server(compiler, { clientLogLevel });
68+
} catch (err) {
69+
error = err;
70+
}
71+
expect(error).toBe(null);
72+
});
73+
74+
it('should allow clientLogLevel to be a "trace"', () => {
75+
let error = null;
76+
try {
77+
const clientLogLevel = 'trace';
78+
server = new Server(compiler, { clientLogLevel });
79+
} catch (err) {
80+
error = err;
81+
}
82+
expect(error).toBe(null);
83+
});
84+
85+
it('should allow clientLogLevel to be a "debug"', () => {
86+
let error = null;
87+
try {
88+
const clientLogLevel = 'debug';
6789
server = new Server(compiler, { clientLogLevel });
6890
} catch (err) {
6991
error = err;

0 commit comments

Comments
 (0)
Please sign in to comment.