easelogger
v1.0.2
Published
A versatile logger module for Node.js with customizable logging levels and transports.
Downloads
1
Maintainers
Readme
Custom Logger
A versatile logger module for Node.js with customizable logging levels and transports.
Installation
To install the package, use npm or yarn:
npm install easelogger
# or
yarn add easelogger
Importing
const Logger = require('easelogger');
// or using ES6 import
import Logger from 'easelogger';
Creating Logger Instances
const fileTransport = new FileTransport({ filename: path.join(__dirname, 'combined.log'), level: LogLevelText.ERROR });
const consoleTransport = new ConsoleTransport();
const logger = new Logger({
transports: [consoleTransport, fileTransport],
});
Logging Levels
Logging Messages
The logger instance supports different log levels:
error(message: string)
warn(message: string)
info(message: string)
success(message: string)
custom(message: string)
Usage
const {ConsoleTransport, CustomLogger} = require('easelogger');
const path = require('path');
// Define file transport
const fileTransport = FileTransport({
filename: path.join(__dirname, 'combined.log'),
level: Logger.LogLevelText.ERROR,
});
// Define console transport
const consoleTransport = new ConsoleTransport();
// Create logger with defined transports
const logger = new CustomLogger({ transports: [consoleTransport, fileTransport] });
Features
- Easy to configure
- Lightweight
- Supports different colors
- Supports file write