Skip to content

Commit 8f91c37

Browse files
snitin315alexander-akait
authored andcommitted
fix: respect infastructureLogging.level for client.logging
1 parent 1841c58 commit 8f91c37

File tree

5 files changed

+493
-7
lines changed

5 files changed

+493
-7
lines changed

lib/Server.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,18 @@ class Server {
218218
...options.client.overlay,
219219
};
220220
}
221+
222+
// Respect infrastructureLogging.level
223+
if (typeof options.client.logging === "undefined") {
224+
const configWithInfrastructureLogging =
225+
configArray.find(
226+
(config) =>
227+
config.infrastructureLogging && config.infrastructureLogging.level
228+
) || configArray[0];
229+
230+
options.client.logging =
231+
configWithInfrastructureLogging.infrastructureLogging.level;
232+
}
221233
}
222234

223235
if (typeof options.compress === "undefined") {

test/fixtures/simple-config/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ module.exports = {
1010
},
1111
node: false,
1212
infrastructureLogging: {
13-
level: "warn",
13+
level: "info",
1414
},
1515
};

test/server/Server.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,66 @@ describe("Server", () => {
283283
},
284284
},
285285
},
286+
{
287+
title:
288+
"single compiler client.logging should default to infrastructureLogging.level",
289+
multiCompiler: false,
290+
options: {},
291+
webpackConfig: {
292+
infrastructureLogging: {
293+
level: "verbose",
294+
},
295+
},
296+
},
297+
{
298+
title:
299+
"single compiler client.logging should override to infrastructureLogging.level",
300+
multiCompiler: false,
301+
options: {
302+
client: {
303+
logging: "none",
304+
},
305+
},
306+
webpackConfig: {
307+
infrastructureLogging: {
308+
level: "verbose",
309+
},
310+
},
311+
},
312+
{
313+
title:
314+
"multi compiler client.logging should respect infrastructureLogging.level",
315+
multiCompiler: true,
316+
options: {},
317+
webpackConfig: [
318+
{},
319+
// infrastructureLogging is set on the second compiler
320+
{
321+
infrastructureLogging: {
322+
level: "warn",
323+
},
324+
},
325+
],
326+
},
327+
{
328+
title:
329+
"multi compiler client.logging should override infrastructureLogging.level",
330+
multiCompiler: true,
331+
options: {
332+
client: {
333+
logging: "none",
334+
},
335+
},
336+
webpackConfig: [
337+
{},
338+
// infrastructureLogging is set on the second compiler
339+
{
340+
infrastructureLogging: {
341+
level: "warn",
342+
},
343+
},
344+
],
345+
},
286346
{
287347
title: "liveReload is true",
288348
multiCompiler: false,

0 commit comments

Comments
 (0)