webpack-log
raw JSON → 3.0.2 verified Sat Apr 25 auth: no javascript
A logger for the Webpack ecosystem, currently at version 3.0.2. This library provides a simple logging API with configurable log levels (trace, debug, info, warn, error, silent), support for timestamps, and unique logger instances to avoid collisions in the Webpack multi-plugin environment. Version 3.0.0 was a complete rewrite, replacing ansi-colors with chalk and uuid with nanoid. It requires Node 8.0.0+. The project is actively maintained with a focus on Webpack plugin and loader development.
Common errors
error TypeError: getLogger is not a function ↓
cause Destructuring the required object as `const { getLogger } = require('webpack-log')` instead of direct assignment.
fix
Change
const { getLogger } = require('webpack-log') to const getLogger = require('webpack-log'). error Error: You must specify a name for the logger ↓
cause Calling `getLogger()` without a `name` in the options object (required in v3).
fix
Add
name to the options: getLogger({ name: 'my-logger' }). error Cannot find module 'webpack-log' ↓
cause Package not installed or wrong package name.
fix
Run
npm install webpack-log --save-dev (or --save if not dev dependency). Warnings
breaking The `colors` option for customizing ANSI colors has been removed in v3. Use `chalk` directly or create your own logger. ↓
fix Remove the `colors` option from logger configuration. If you need custom colors, fork the package or use `chalk` manually.
deprecated The `colors` property on the logger instance (e.g., `log.colors`) is deprecated in v3. ↓
fix Access color formatting through `chalk` instead of `log.colors`.
gotcha Loggers with the same `name` are cached by default (unique: true), meaning two calls with the same name return the same instance. To create distinct loggers, set `unique: true` explicitly. ↓
fix In v2 and below, use `unique: true` to avoid sharing loggers. In v3, unique defaults to true, so no change needed.
Install
npm install webpack-log yarn add webpack-log pnpm add webpack-log Imports
- getLogger wrong
const { getLogger } = require('webpack-log')correctimport getLogger from 'webpack-log' - LoggerOptions wrong
import { LoggerOptions } from 'webpack-log'correcttype LoggerOptions = { name?: string; level?: string; timestamp?: boolean; unique?: boolean } - getLogger (CJS) wrong
const { getLogger } = require('webpack-log')correctconst getLogger = require('webpack-log')
Quickstart
const getLogger = require('webpack-log');
const log = getLogger({ name: 'my-plugin', level: 'info', timestamp: true });
log.info('Logger initialized successfully');
log.warn('This is a warning');
log.error('An error occurred');
log.debug('This debug message will not appear because level is info');