reLogger
is a customizable logging utility for Node.js that supports dynamic log levels and colored output using chalk
. It allows you to define custom log levels and their corresponding colors, making it easy to create a logging system tailored to your needs.
You can install reLogger
via npm:
npm install relogger-x
First, import the reLogger
class and create an instance with your desired main color and custom log levels.
import reLogger from 'relogger';
const logger = new reLogger("blue", {
info: "blue",
error: "red",
warn: "yellow",
});
logger.info("This is an info message");
logger.error("This is an error message");
logger.warn("This is a warning message");
You can define custom log levels and their corresponding colors when creating an instance of reLogger
.
const logger = new reLogger("cyan", {
debug: "gray",
success: "green",
});
logger.debug("Debugging information");
logger.success("Operation successful");
reLogger
automatically uses the system's timezone to generate timestamps. The timestamp is displayed in the format [DD.MM.YYYY | HH:mm:ss]
.
Creates a new instance of reLogger
.
mainColor
: The main color for the timestamp in the log output.customLevels
: An object defining custom log levels and their corresponding colors.
For each log level defined in customLevels
, a corresponding method is dynamically created on the reLogger
instance. These methods take a message and optional additional arguments, and return the formatted log output.
logger.customLevel("This is a custom level message", additionalArg1, additionalArg2);
Here is a complete example demonstrating the usage of reLogger
:
import reLogger from 'relogger';
const logger = new reLogger("magenta", {
info: "blue",
error: "red",
warn: "yellow",
debug: "gray",
success: "green",
});
logger.info("This is an info message");
logger.error("This is an error message");
logger.warn("This is a warning message");
logger.debug("Debugging information");
logger.success("Operation successful");
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
This project is licensed under the MIT License.
Enjoy logging with reLogger
! If you have any questions or feedback, feel free to reach out.