
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
webpack-log
Advanced tools
The webpack-log package is a logging utility used in the webpack ecosystem. It provides a way to output logs with different levels of severity, such as 'info', 'warn', and 'error'. It is designed to work with webpack's node.js API and plugins to provide a consistent logging experience.
Creating a logger instance
This code sample demonstrates how to create a new logger instance with a specified name. The logger can then be used to output informational messages.
const log = require('webpack-log');
const logger = log({ name: 'wds' });
logger.info('Server is starting...');
Logging warnings
This code sample shows how to log a warning message using the logger instance created earlier.
logger.warn('This is a warning message.');
Logging errors
This code sample illustrates how to log an error message, which could be used to output error information during the build process or plugin execution.
logger.error('An error has occurred!');
Signale is a console logger with a focus on providing beautiful output. It offers various log levels and custom loggers with configurable log messages. Compared to webpack-log, Signale is more versatile and can be used outside of the webpack context.
Winston is a multi-transport async logging library for Node.js. It supports different storage options for log messages, such as files, databases, or third-party services. While webpack-log is specific to webpack, Winston is a more general-purpose logging solution with extensive features.
Consola provides an easy-to-use and intuitive console logger. It is designed to work on both Node.js and browser environments and offers a variety of reporter options. Unlike webpack-log, Consola can be used for a wide range of applications, not limited to webpack.
A common logging module for the Webpack ecosystem. webpack-log
leverages
loglevelnext
.
First thing's first, install the module:
npm install webpack-log --save
Note: We do not recommend installing this module globally.
webpack-log
requires Node v6 or higher.
const weblog = require('webpack-log');
const log = weblog({ name: 'wds' }) // webpack-dev-server
log.info('Server Starting');
The code above will produce:
The default export (function
) will return a logger, given an options
Object.
The following is a property reference for the Object.
Note: the logger returned is unique by default, due to the nature of the webpack
ecosystem. Please reference the unique
option below for disabling
this feature and to force caching.
Type: String
Default: 'info'
Specifies the level the logger should use. A logger will not produce output for any log level beneath the specified level. Available levels and order are:
[
'trace',
'debug',
'info',
'warn',
'error',
'silent'
]
Note: The level names shown above correspond to the available logging methods,
with the notable exception of the silent
level.
Required
Type: String
Default: '<unknown>'
Specifies the name of the log to create. This property is required, and used to
differentiate between loggers when webpack-log
is used in multiple projects
executing in the same process space.
Type: Boolean
Default: false
If true
, instructs the logger to display a timestamp for log output, preceding
all other data.
Type: Boolean
Default: true
If false
, instructs the logger to used cached versions of a log with the same
name. Due to the nature of the webpack
ecosystem and multiple plugin/loader
use in the same process space, loggers are created as unique instances by default.
By passing false
for this property, the module is instructed to cache the
requested logger.
We welcome your contributions! Please have a read of CONTRIBUTING.md for more information on how to get involved.
FAQs
A logger for the Webpack ecosystem
The npm package webpack-log receives a total of 3,452,326 weekly downloads. As such, webpack-log popularity was classified as popular.
We found that webpack-log demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.