Skip to content

Commit

Permalink
feat(client): delete none and warning because they are deprecated
Browse files Browse the repository at this point in the history
ISSUE: #1901
  • Loading branch information
hiroppy committed Jun 8, 2019
1 parent dfe1a4f commit cb7e81a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 42 deletions.
15 changes: 3 additions & 12 deletions client-src/default/utils/log.js
Expand Up @@ -8,11 +8,6 @@ const ERROR = 'error';
const DEBUG = 'debug';
const TRACE = 'trace';
const SILENT = 'silent';
// deprecated
// TODO: remove these at major released
// https://github.com/webpack/webpack-dev-server/pull/1825
const WARNING = 'warning';
const NONE = 'none';

// Set the default log level
log.setDefaultLevel(INFO);
Expand All @@ -26,17 +21,13 @@ export function setLogLevel(level) {
case TRACE:
log.setLevel(level);
break;
// deprecated
case WARNING:
// loglevel's warning name is different from webpack's
log.setLevel('warn');
break;
// deprecated
case NONE:
case SILENT:
log.disableAll();
break;
default:
if (level === 'none' || level === 'warning') {
log.error('[WDS] "none" and "warning" have been deprecated.');
}
log.error(`[WDS] Unknown clientLogLevel '${level}'`);
}
}
11 changes: 1 addition & 10 deletions lib/options.json
Expand Up @@ -37,16 +37,7 @@
]
},
"clientLogLevel": {
"enum": [
"info",
"warn",
"error",
"debug",
"trace",
"silent",
"none",
"warning"
]
"enum": ["info", "warn", "error", "debug", "trace", "silent"]
},
"compress": {
"type": "boolean"
Expand Down
20 changes: 17 additions & 3 deletions test/client/utils/__snapshots__/log.test.js.snap
@@ -1,5 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`log should output exception log when the level is deprecated 1`] = `
Array [
Array [
"[WDS] \\"none\\" and \\"warning\\" have been deprecated.",
],
Array [
"[WDS] Unknown clientLogLevel 'none'",
],
Array [
"[WDS] \\"none\\" and \\"warning\\" have been deprecated.",
],
Array [
"[WDS] Unknown clientLogLevel 'warning'",
],
]
`;

exports[`log should output exception log when the level is unknown 1`] = `"[WDS] Unknown clientLogLevel 'foo'"`;

exports[`log should set log level via setLogLevel 1`] = `
Expand All @@ -19,8 +36,5 @@ Array [
Array [
"trace",
],
Array [
"warn",
],
]
`;
18 changes: 14 additions & 4 deletions test/client/utils/log.test.js
Expand Up @@ -35,7 +35,7 @@ describe('log', () => {
});

test('should set log level via setLogLevel', () => {
['info', 'warn', 'error', 'debug', 'trace', 'warning'].forEach((level) => {
['info', 'warn', 'error', 'debug', 'trace'].forEach((level) => {
setLogLevel(level);
});

Expand All @@ -44,14 +44,14 @@ describe('log', () => {
).toMatchSnapshot();
});

test('should set none and silent via setLogLevel', () => {
['none', 'silent'].forEach((level) => {
test('should set silent via setLogLevel', () => {
['silent'].forEach((level) => {
setLogLevel(level);
});

expect(
logMock.getLogger.mock.results[0].value.disableAll.mock.results
).toHaveLength(2);
).toHaveLength(1);
});

test('should output exception log when the level is unknown', () => {
Expand All @@ -61,4 +61,14 @@ describe('log', () => {
logMock.getLogger.mock.results[0].value.error.mock.calls[0][0]
).toMatchSnapshot();
});

test('should output exception log when the level is deprecated', () => {
['none', 'warning'].forEach((level) => {
setLogLevel(level);
});

expect(
logMock.getLogger.mock.results[0].value.error.mock.calls
).toMatchSnapshot();
});
});
15 changes: 2 additions & 13 deletions test/options.test.js
Expand Up @@ -121,19 +121,8 @@ describe('options', () => {
failure: [false],
},
clientLogLevel: {
success: [
'silent',
'info',
'error',
'warn',
'trace',
'debug',
// deprecated
'none',
// deprecated
'warning',
],
failure: ['whoops!'],
success: ['silent', 'info', 'error', 'warn', 'trace', 'debug'],
failure: ['whoops!', 'none', 'warning'],
},
compress: {
success: [true],
Expand Down

0 comments on commit cb7e81a

Please sign in to comment.