diff --git a/src/BundleAnalyzerPlugin.js b/src/BundleAnalyzerPlugin.js index 1fa5253a..20b10443 100644 --- a/src/BundleAnalyzerPlugin.js +++ b/src/BundleAnalyzerPlugin.js @@ -28,15 +28,16 @@ class BundleAnalyzerPlugin { }; this.server = null; - this.logger = new Logger(this.opts.logLevel); } apply(compiler) { this.compiler = compiler; // Respect default logging level from webpack - const defaultLoggerLevel = compiler.options.infrastructureLogging && compiler.options.infrastructureLogging.level ? compiler.options.infrastructureLogging.level : this.opts.logLevel; - this.logger = compiler.getInfrastructureLogger ? compiler.getInfrastructureLogger('webpack-bundle-analyzer') : new Logger(defaultLoggerLevel); + const defaultLoggerLevel = compiler.options.infrastructureLogging && compiler.options.infrastructureLogging.level ? + compiler.options.infrastructureLogging.level : this.opts.logLevel; + this.logger = compiler.getInfrastructureLogger ? + compiler.getInfrastructureLogger('webpack-bundle-analyzer') : new Logger(defaultLoggerLevel); const done = (stats, callback) => { callback = callback || (() => {}); diff --git a/src/Logger.js b/src/Logger.js index 35e8c201..77478bad 100644 --- a/src/Logger.js +++ b/src/Logger.js @@ -23,7 +23,7 @@ const LEVEL_TO_CONSOLE_METHOD = new Map([ ['warn', 'log'] ]); -const webpackLogger = require('webpack/lib/logging/runtime') +const webpackLogger = require('webpack/lib/logging/runtime'); if (webpackLogger.getLogger) LEVELS.push(...loggerMethods); @@ -50,7 +50,7 @@ class Logger { _log(level, ...args) { if (webpackLogger.getLogger) { - webpackLogger.getLogger('webpack-bundle-analyzer')[level](...args) + webpackLogger.getLogger('webpack-bundle-analyzer')[level](...args); } else { console[LEVEL_TO_CONSOLE_METHOD.get(level) || level](...args); } @@ -66,4 +66,4 @@ LEVELS.forEach(level => { }; }); -module.exports = Logger +module.exports = Logger;