What is @pnpm/logger?
@pnpm/logger is a logging utility designed for use with the pnpm package manager. It provides a structured way to log messages with different levels of severity and categories, making it easier to track and debug issues in pnpm-related projects.
What are @pnpm/logger's main functionalities?
Basic Logging
This feature allows you to log messages with different levels of severity such as info, warn, and error.
const logger = require('@pnpm/logger')('my-logger');
logger.info({ message: 'This is an info message' });
logger.warn({ message: 'This is a warning message' });
logger.error({ message: 'This is an error message' });
Custom Loggers
You can create custom loggers with specific namespaces to better organize your logging output.
const logger = require('@pnpm/logger');
const customLogger = logger('custom-namespace');
customLogger.info({ message: 'This is a custom info message' });
Structured Logging
This feature allows you to log structured data, making it easier to filter and analyze logs.
const logger = require('@pnpm/logger')('structured-logger');
logger.info({ event: 'user_signup', userId: 12345, message: 'User signed up successfully' });
Other packages similar to @pnpm/logger
winston
Winston is a versatile logging library for Node.js that supports multiple transports (e.g., console, file, HTTP) and log levels. It offers more flexibility and customization options compared to @pnpm/logger.
bunyan
Bunyan is a simple and fast JSON logging library for Node.js. It provides a structured logging format and includes features like log rotation and streaming. It is similar to @pnpm/logger in terms of structured logging but offers additional features like log rotation.
pino
Pino is a low-overhead logging library for Node.js that focuses on performance. It provides fast and efficient logging with a simple API. Pino is more performance-oriented compared to @pnpm/logger.
@pnpm/logger
Logger for pnpm
Installation
pnpm add @pnpm/logger
Usage
@pnpm/logger
is mostly just a wrapper over bole.
Logging is done the same way as in bole. To listed for logs, use streamParser
or create
a new parser with createStreamParser()
.
import logger, {streamParser} from '@pnpm/logger'
logger.debug({ foo: 'bar' })
streamParser.on('data', msg => {
})
License
MIT