Package Exports
- logger-standard
- logger-standard/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (logger-standard) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
đ 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.