@carrot-foundation/web-logger
v0.4.0
Published
A lightweight logging library for web applications built on top of [Pino](https://github.com/pinojs/pino).
Downloads
902
Readme
@carrot-foundation/web-logger
A lightweight logging library for web applications built on top of Pino.
Installation
npm install @carrot-foundation/web-loggeror
pnpm add @carrot-foundation/web-loggeror
yarn add @carrot-foundation/web-loggerUsage
import { logger } from '@carrot-foundation/web-logger';
// Log messages at different levels
logger.info('Application started');
logger.debug('Debug information');
logger.warn('Warning message');
logger.error('Error occurred');
// Log with additional context
logger.info({ userId: '123', action: 'login' }, 'User logged in');
// Log errors with context
try {
// some code
} catch (error) {
logger.error({ error }, 'Operation failed');
}Features
- Built on top of Pino for high-performance logging
- Simple and intuitive API
- Structured logging support
- Lightweight with minimal dependencies
- ESM module support
API
The logger instance is a configured Pino logger with all standard Pino methods available:
logger.trace()- Log at trace levellogger.debug()- Log at debug levellogger.info()- Log at info levellogger.warn()- Log at warn levellogger.error()- Log at error levellogger.fatal()- Log at fatal level
For more advanced usage and configuration options, refer to the Pino documentation.
