Skip to content

Commit

Permalink
fix: update clientLogLevel to match docs and error (#1825)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabemeola authored and hiroppy committed Apr 27, 2019
1 parent b5bc05c commit 7f52bbf
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
3 changes: 2 additions & 1 deletion bin/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ const options = {
type: 'string',
group: DISPLAY_GROUP,
default: 'info',
describe: 'Log level in the browser (info, warning, error or none)',
describe:
'Log level in the browser (trace, debug, info, warn, error or silent)',
},
https: {
type: 'boolean',
Expand Down
15 changes: 8 additions & 7 deletions client-src/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ let useErrorOverlay = false;
let useProgress = false;

const INFO = 'info';
const WARNING = 'warning';
const WARN = 'warn';
const ERROR = 'error';
const NONE = 'none';
const DEBUG = 'debug';
const TRACE = 'trace';
const SILENT = 'silent';

// Set the default log level
log.setDefaultLevel(INFO);
Expand Down Expand Up @@ -108,14 +110,13 @@ const onSocketMsg = {
}
switch (level) {
case INFO:
case WARN:
case DEBUG:
case TRACE:
case ERROR:
log.setLevel(level);
break;
case WARNING:
// loglevel's warning name is different from webpack's
log.setLevel('warn');
break;
case NONE:
case SILENT:
log.disableAll();
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
]
},
"clientLogLevel": {
"enum": ["none", "info", "error", "warning"]
"enum": ["info", "warn", "error", "debug", "trace", "silent"]
},
"compress": {
"type": "boolean"
Expand Down Expand Up @@ -354,7 +354,7 @@
"bonjour": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverbonjour)",
"ca": "should be {String|Buffer}",
"cert": "should be {String|Buffer}",
"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)",
"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)",
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)",
Expand Down
8 changes: 5 additions & 3 deletions test/options/__snapshots__/options.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Object {
"cert": "should be {String|Buffer}",
"clientLogLevel": "should be {String} and equal to one of the allowed values
[ 'none', 'info', 'error', 'warning' ]
[ 'info', 'warn', 'error', 'debug', 'trace', 'silent' ]
(https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
Expand Down Expand Up @@ -109,10 +109,12 @@ Object {
},
"clientLogLevel": Object {
"enum": Array [
"none",
"info",
"warn",
"error",
"warning",
"debug",
"trace",
"silent",
],
},
"compress": Object {
Expand Down
30 changes: 26 additions & 4 deletions test/options/clientLogLevel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ describe('Validation', () => {
}
});

it('should allow clientLogLevel to be a "none"', () => {
it('should allow clientLogLevel to be a "silent"', () => {
let error = null;
try {
const clientLogLevel = 'none';
const clientLogLevel = 'silent';
server = new Server(compiler, { clientLogLevel });
} catch (err) {
error = err;
Expand Down Expand Up @@ -60,10 +60,32 @@ describe('Validation', () => {
expect(error).toBe(null);
});

it('should allow clientLogLevel to be a "warning"', () => {
it('should allow clientLogLevel to be a "warn"', () => {
let error = null;
try {
const clientLogLevel = 'warning';
const clientLogLevel = 'warn';
server = new Server(compiler, { clientLogLevel });
} catch (err) {
error = err;
}
expect(error).toBe(null);
});

it('should allow clientLogLevel to be a "trace"', () => {
let error = null;
try {
const clientLogLevel = 'trace';
server = new Server(compiler, { clientLogLevel });
} catch (err) {
error = err;
}
expect(error).toBe(null);
});

it('should allow clientLogLevel to be a "debug"', () => {
let error = null;
try {
const clientLogLevel = 'debug';
server = new Server(compiler, { clientLogLevel });
} catch (err) {
error = err;
Expand Down

0 comments on commit 7f52bbf

Please sign in to comment.