console-colorizer-adnan
v1.0.3
Published
A simple npm package to colorize console logs
Maintainers
Readme
Console Colorizer
A simple and lightweight npm package to add beautiful colors to your console output. Make your terminal logs more readable and visually appealing with easy-to-use color functions.
🎨 Features
- Simple API - Easy to use color functions
- Lightweight - Minimal dependencies, fast performance
- ANSI Colors - Standard terminal color support
- Shortcut Loggers - Direct console logging with colors
- Node.js Compatible - Works in any Node.js environment
📦 Installation
npm install console-colorizer-adnan🚀 Quick Start
const { colorize, log } = require('console-colorizer-adnan');
// Colorize any text
console.log(colorize("This is red text", "red"));
console.log(colorize("This is green text", "green"));
// Use shortcut loggers
log.red("Error: Something went wrong!");
log.green("Success: Operation completed!");
log.yellow("Warning: Check your inputs!");📚 API Reference
colorize(text, color)
Colorizes the given text with the specified color.
Parameters:
text(string) - The text to colorizecolor(string) - The color name (see available colors below)
Returns: (string) - The colorized text
Example:
const { colorize } = require('console-colorizer-adnan');
const message = colorize("Hello World!", "blue");
console.log(message);log Object
Provides shortcut methods for direct console logging with colors.
Available Methods:
log.red(message)log.green(message)log.yellow(message)log.blue(message)log.magenta(message)log.cyan(message)log.white(message)
Example:
const { log } = require('console-colorizer-adnan');
log.red("This is a red error message");
log.green("This is a green success message");
log.yellow("This is a yellow warning message");🎨 Available Colors
| Color | Description |
|-------|-------------|
| red | Red text |
| green | Green text |
| yellow | Yellow text |
| blue | Blue text |
| magenta | Magenta text |
| cyan | Cyan text |
| white | White text |
💡 Usage Examples
Basic Usage
const { colorize, log } = require('console-colorizer-adnan');
// Colorize individual strings
console.log(colorize("Processing...", "yellow"));
console.log(colorize("✓ Completed", "green"));
// Use shortcut loggers
log.blue("Starting application...");
log.green("✓ Server started successfully!");
log.red("✗ Database connection failed");Error Handling
const { log } = require('console-colorizer-adnan');
try {
// Some operation
throw new Error("Something went wrong");
} catch (error) {
log.red(`Error: ${error.message}`);
}Status Messages
const { log } = require('console-colorizer-adnan');
function processData(data) {
log.cyan("Processing data...");
if (data.length === 0) {
log.yellow("Warning: No data to process");
return;
}
// Process data
log.green(`Successfully processed ${data.length} items`);
}🔧 Development
Running Tests
node test.jsProject Structure
console-colorizer/
├── index.js # Main package file
├── test.js # Test examples
├── package.json # Package configuration
└── README.md # This file🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the ISC License.
🔗 Links
- GitHub: https://github.com/adnan-revnix/console-colorizer-adnan
- Issues: https://github.com/adnan-revnix/console-colorizer-adnan/issues
- NPM: https://www.npmjs.com/package/console-colorizer-adnan
⭐ Support
If you find this package helpful, please consider giving it a star on GitHub!
Made with ❤️ by Adnan
