A simple Node.js logger class for printing colorful console logs using the chalk
module. It supports various log levels with color-coded messages.
To install the module using npm, run the following command in your terminal:
npm install @vlodia/logger
yarn add @vlodia/logger
const { Logger } = require("@vlodia/logger");
// Create an instance of Logger
const logger = new Logger("MyApp");
// Print log messages
logger.log("This is a log message.");
logger.info("This is an info message.");
logger.warn("This is a warning message.");
logger.error("This is an error message.");
logger.success("This is a success message.");
- log(message: string): General log messages.
- info(message: string): Information messages.
- warn(message: string): Warning messages.
- error(message: string): Error messages.
- success(message: string): Success messages.
- Log messages are printed to the console with timestamp and a custom prefix in colorful format.
const express = require("express");
const app = express();
const { Logger } = require('@vlodia/logger');
const logger = new Logger('APP:')
app.get("/", (req, res) => res.send("Express"));
app.listen(3000, () => {
logger.info("Starting in port 3000)
logger.success("Connected succesfully")
});
module.exports = app;
- It will look like this in the terminal
- This module is open source. You can contribute by adding new features or fixing bugs and sending a pull request to the GitHub repository.
- This project is licensed under the Apache-v2.0 License. For details, see the LICENSE file.