What is @changesets/logger?
@changesets/logger is a logging utility designed to be used with the Changesets tool. It provides a simple and consistent way to log messages, warnings, and errors during the process of managing versioning and changelogs for a monorepo or multi-package repository.
What are @changesets/logger's main functionalities?
Logging Info Messages
This feature allows you to log informational messages. The `info` function is used to log messages that are meant to inform the user about the current state or progress of a process.
const { info } = require('@changesets/logger');
info('This is an info message');
Logging Warning Messages
This feature allows you to log warning messages. The `warn` function is used to log messages that indicate a potential issue or something that the user should be cautious about.
const { warn } = require('@changesets/logger');
warn('This is a warning message');
Logging Error Messages
This feature allows you to log error messages. The `error` function is used to log messages that indicate a failure or critical issue that needs immediate attention.
const { error } = require('@changesets/logger');
error('This is an error message');
Logging Success Messages
This feature allows you to log success messages. The `success` function is used to log messages that indicate a successful operation or completion of a task.
const { success } = require('@changesets/logger');
success('This is a success message');
Other packages similar to @changesets/logger
winston
Winston is a versatile logging library for Node.js that supports multiple transports (e.g., console, file, HTTP). It is more feature-rich compared to @changesets/logger, offering advanced logging capabilities such as log levels, custom formats, and more.
pino
Pino is a fast and low-overhead logging library for Node.js. It is designed for high-performance logging and is suitable for production environments. Compared to @changesets/logger, Pino offers better performance and more advanced features like log redaction and serializers.
bunyan
Bunyan is a simple and fast JSON logging library for Node.js. It is designed to produce logs in a structured JSON format, making it easy to parse and analyze logs. Bunyan offers more advanced features than @changesets/logger, such as log streams and child loggers.
@changesets/logger
Usage
import { error } from '@changesets/logger";
error('message part 1', 'message part 2');
Package Exports
error: Use error
to print error messages upon which users which immediately action to complete the task.
info: Use info
to print informational messages to user.
log: Use log
to print messages don't fall in any other specific category. For example, message to show title of the step being performed by the changesets tool.
success: Use success
to assert to users that their instructions have completed successfully.
warn: Use warn
to print warning messages, something that user could action on now or later without much impact of their work.
Silencing Messages In Tests
Use the @changesets/test-utils
package to silence the logs in test cases.
For example:
import { temporarilySilenceLogs } from "@changesets/test-utils";
import { log } from "@changesets/logger";
temporarilySilenceLogs();
log("I am not logged");
console.log("Yay, I am logged");