Lovely Logs is a lightweight, customizable logging library for Node.js and browser environments that enhances your console logs with beautiful colors and styles. With Lovely Logs, you can quickly and easily differentiate between different types of logs, making it easier to identify and debug issues in your application.
To install Lovely Logs, simply run the following command:
npm install lovely-logs
or
yarn add lovely-logs
or
pnpm add lovely-logs
Import the logger
class from the lovely-logs
package:
⚠️ By default, the 'web' platform is used. If you want to use it on a Terminal, please use 'console' platform. See Advanced Usage for more information.
import { logger } from "lovely-logs"
// Now you can use the available logging methods to print messages to the console:
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")
Start by importing the createLogger
class from the lovely-logs
package:
import { createLogger } from "lovely-logs"
Call createLogger function with your desired configuration:
createLogger({
platform: "console",
timestampEnabled: true,
// more options coming soon
})
You can choose between the 'web' and 'console' platforms by setting the platform option to the desired value. By default, the 'web' platform is used.
Now you can use all around your code the available logging methods to print messages to the console:
import { Logger } from "lovely-logs"
// These are configured from the previous createLogger function
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")
To use custom log styles, you can call the custom
method:
Logger.custom(modeText: string, style: string, printTime: boolean, ...msgs: any[]);
You can customize permanently the appearance of your logs by modifying the logStyle
and modeText
properties of the Logger
class:
// Only used on website
Logger.logStyle.info = "background: #customColor; color: #customTextColor; ..."
Logger.modeText["web"].info = "CUSTOM_INFO"
// This will change the styled output text from "INFO" to "CUSTOM_INFO"
Logger.modeText["console"].info = "CUSTOM_INFO"
// This will change the output text from "ℹ" to "CUSTOM_INFO"
Lovely Logs is open-source software licensed under the MIT License.
Contributions are welcome! Please read our contributing guidelines for more information.
If you encounter any issues or have questions, please feel free to open an issue on our GitHub repository.
Happy logging! 🌈