logger-standard
v1.0.2
Published
A simple and flexible logging utility for Node.js applications. π
Downloads
82
Maintainers
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.