From 7f52bbfc131c403736f5922b8aec3df817314a0b Mon Sep 17 00:00:00 2001 From: Gabe M Date: Sat, 27 Apr 2019 13:05:26 -0600 Subject: [PATCH] fix: update clientLogLevel to match docs and error (#1825) --- bin/options.js | 3 +- client-src/default/index.js | 15 +++++----- lib/options.json | 4 +-- .../__snapshots__/options.test.js.snap | 8 +++-- test/options/clientLogLevel.test.js | 30 ++++++++++++++++--- 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/bin/options.js b/bin/options.js index 0e284ce5c6..f4c7f8919e 100644 --- a/bin/options.js +++ b/bin/options.js @@ -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', diff --git a/client-src/default/index.js b/client-src/default/index.js index 8a2d8e1e25..ef1ae918d7 100644 --- a/client-src/default/index.js +++ b/client-src/default/index.js @@ -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); @@ -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: diff --git a/lib/options.json b/lib/options.json index 5a36658586..9608b391d5 100644 --- a/lib/options.json +++ b/lib/options.json @@ -37,7 +37,7 @@ ] }, "clientLogLevel": { - "enum": ["none", "info", "error", "warning"] + "enum": ["info", "warn", "error", "debug", "trace", "silent"] }, "compress": { "type": "boolean" @@ -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)", diff --git a/test/options/__snapshots__/options.test.js.snap b/test/options/__snapshots__/options.test.js.snap index a5c8567907..69f5d6b6e6 100644 --- a/test/options/__snapshots__/options.test.js.snap +++ b/test/options/__snapshots__/options.test.js.snap @@ -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)", @@ -109,10 +109,12 @@ Object { }, "clientLogLevel": Object { "enum": Array [ - "none", "info", + "warn", "error", - "warning", + "debug", + "trace", + "silent", ], }, "compress": Object { diff --git a/test/options/clientLogLevel.test.js b/test/options/clientLogLevel.test.js index 79c3652d5c..38e477b05b 100644 --- a/test/options/clientLogLevel.test.js +++ b/test/options/clientLogLevel.test.js @@ -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; @@ -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;