Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@wdio/logger
Advanced tools
The @wdio/logger package is a utility used within the WebdriverIO testing framework to facilitate logging. It allows developers to create namespaced loggers that can be used to output messages to the console or to files, depending on the configuration. It is designed to work seamlessly with the WebdriverIO ecosystem but can also be used independently for logging purposes in Node.js applications.
Creating a Logger Instance
This feature allows you to create a new logger instance with a specific namespace. You can then use this instance to log messages at different levels, such as info, warn, error, etc.
const logger = require('@wdio/logger').default('my-logger');
logger.info('This is an info message.');
Setting Log Levels
This feature allows you to set the log level for a specific logger instance. Messages below the set level will not be logged.
const logger = require('@wdio/logger').default('my-logger');
logger.setLevel('info');
logger.info('This will be logged.');
logger.debug('This will not be logged.');
Logging Messages
This feature is used to log messages at different severity levels. The available methods are info, warn, error, and others, each corresponding to a level of importance.
const logger = require('@wdio/logger').default('my-logger');
logger.info('Informational message');
logger.warn('Warning message');
logger.error('Error message');
Winston is a multi-transport async logging library for Node.js. It is one of the most popular logging libraries and offers more flexibility and configuration options compared to @wdio/logger. It supports multiple storage options for logs, such as files, databases, and remote services.
Pino is a very low overhead Node.js logger, which focuses on performance. It provides a different set of trade-offs compared to @wdio/logger, emphasizing speed and efficiency over configurability and integration with specific frameworks like WebdriverIO.
Bunyan is a simple and fast JSON logging library for Node.js services. It has similar functionalities to @wdio/logger but also includes features like log rotation and streams, which can be more suitable for complex logging needs.
A helper utility for logging of WebdriverIO packages
This package is used across all WebdriverIO packages to log information using the loglevel
package. It can also be used for any other arbitrary Node.js project.
To install the package just call
npm install @wdio/logger
or when adding it to a WebdriverIO subpackage:
lerna add @wdio/logger --scope <subpackage>
The package exposes a logger function that you can use to register an instance for your scoped package:
import logger from '@wdio/logger'
const log = logger('myPackage')
log.info('some logs')
For more info see loglevel
package on NPM.
This package extends the log levels available in loglevel
by introducing a new level called progress
.
The progress
level is particularly useful when you need to dynamically update a specific line in the terminal. For example, it can be utilized to display the download progress of browsers or drivers.
Notably, the progress
level is equivalent to the info
level. Therefore, if you set the log level to error
or silent
, any progress
logs will be suppressed.
It's important to mention that progress
writes directly to process.stdout
, and these logs won't be captured in any log files.
To ensure consistent formatting with subsequent logs while using progress
, it's essential to clear it at the end. To do so, simply call progress
with an empty string, which will clear the last line:
log.progress('')
import logger from '@wdio/logger';
const log = logger('internal');
const totalSize = 100;
let uploadedSize = 0;
const uploadInterval = setInterval(() => {
const chunkSize = 10;
uploadedSize += chunkSize;
const data = `Progress: ${(uploadedSize * 100) / totalSize}%`;
log.progress(data);
if (uploadedSize >= totalSize) {
clearInterval(uploadInterval);
log.progress(''); // Called at the end to maintain the alignment of subsequent logs.
console.log('Upload complete.');
}
}, 100);
v9.1.3 (2024-10-08)
wdio-browser-runner
, wdio-logger
, webdriverio
webdriverio
wdio-sauce-service
, wdio-spec-reporter
webdriverio
webdriver
wdio-browser-runner
FAQs
A helper utility for logging of WebdriverIO packages
The npm package @wdio/logger receives a total of 1,591,155 weekly downloads. As such, @wdio/logger popularity was classified as popular.
We found that @wdio/logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.