1.0.2 âĸ Published 9 months ago
logger-standard v1.0.2
đ logger-standard
A simple and flexible logging utility for Node.js applications. đ
đ ī¸ Installation
npm install logger-standard
đ Usage
import { Logger } from 'logger-standard';
// Create a new logger instance
const logger = new Logger({
service: 'MyService',
showDate: true
});
// Basic logging
logger.info('This is an info message');
logger.error('This is an error message');
logger.warn('This is a warning message');
logger.log('This is a regular log message');
// Logging with sensor ID
logger.info('Temperature reading', 'TEMP001');
đ API
Constructor
new Logger(options)
options.service
(string): Prefix for all log messages. Default: ''options.showDate
(boolean): Include timestamp in log messages. Default: false
Methods
info(message, sensorId)
: Log an info message âšī¸error(message, sensorId)
: Log an error message âwarn(message, sensorId)
: Log a warning message â ī¸log(message, sensorId)
: Log a regular message đĸ
All methods accept two parameters:
message
(string): The message to logsensorId
(string, optional): An identifier for the source of the log
đ¨ī¸ Output Format
The log output format is as follows:
[Timestamp (if enabled)] [Service Name] Message (sensorId: SensorID)
đ Dependencies
This package relies on the following npm packages for colored console output:
- console-error
- console-info
- console-warn
đ¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
đ Issues
If you encounter any problems or have any questions, please open an issue in the GitHub repository.
đ License
This project is licensed under the ISC License.