nubo-logger
v3.6.9
Published
A colorful console logger utility for development
Maintainers
Readme
🌈 Nubo Logger
A beautiful, colorful console logger utility for TypeScript/JavaScript development that makes debugging enjoyable!
✨ Features
- 🎨 Provides multiple color options for better log visualization.
- 🧠 Includes full TypeScript support with type definitions.
- ⚡ Has zero dependencies, making it lightweight and fast.
- 🌍 Automatically disables logging in production environments.
- 🔧 Offers a simple and easy-to-use API.
- 🔁 Supports both ESM and CommonJS module systems.
📦 Installation
npm install nubo-logger
# or
yarn add nubo-logger
# or
pnpm add nubo-logger
# or
bun add nubo-logger🚀 Usage
Basic Usage
import log from "nubo-logger";
// log.t adds a timestamp to the output
// log.b makes the output bold
// log.t.b applies both timestamp and bold formatting
log.t.mint("[scope]", "This is a mint message with additional description");
log.mint("[scope]");
log.t.mint("[scope] with time");
log.b.mint("[scope]", "All string in bold");
log.t.b.mint("[scope]", "All string in bold", "ISOString + bold");Advanced Usage
import { NuboLogger } from "nubo-logger";
const logger = new NuboLogger({ enableInProduction: true });
logger.b.mint("[scope-2]", "This is a mint message with additional description");
logger.t.indigo("[scope-2]", "This is an indigo debug message with ISOString");
logger.cyan("[scope-2]", "@cyan", "Scope");🎨 Available Colors
| Method | Color | Use Case |
|-------------|----------|-------------------------------|
| blue() | 🔵 Blue | Information, links |
| brown() | 🟤 Brown | Logs related to storage/files |
| cyan() | 🔷 Cyan | Highlights, emphasis |
| gray() | ⚫ Gray | Less important info |
| gray2() | ⚫ Gray2 | Slightly darker info |
| gray3() | ⚫ Gray3 | Darker muted info |
| gray4() | ⚫ Gray4 | Even darker info |
| gray5() | ⚫ Gray5 | Near-black info |
| gray6() | ⚫ Gray6 | Background black |
| green() | 🟢 Green | Success, completion |
| indigo() | 🟣 Indigo| Accents, strong debug |
| label() | ⚪ Label | Bright white foreground |
| mint() | 🟢 Mint | Fresh, success with emphasis |
| orange() | 🟠 Orange| Warnings, important notes |
| pink() | 🌸 Pink | Friendly or soft emphasis |
| purple() | 🟣 Purple| Debug, special notes |
| red() | 🔴 Red | Errors, critical issues |
| teal() | 🟦 Teal | Calm or balanced output |
| yellow() | 🟡 Yellow| Warnings, attention |
📊 Log Levels
| Method | Level | Description | Example Usage |
|-----------|---------|-------------------------------|--------------------------------------------|
| error() | Error | Critical errors and exceptions| log.error("Critical failure:", error); |
| warn() | Warning | Warning messages | log.warn("Deprecated API usage."); |
| info() | Info | General information | log.info("User logged in successfully.");|
| debug() | Debug | Debug information | log.debug("Fetching user data:", userId);|
⚙ Configuration
interface NuboLoggerOptions {
enableInProduction?: boolean; // Optional, default: false
}
// Default configuration disables logging in production
const defaultLogger = new NuboLogger();
// Custom configuration to enable logging in production
const logger = new NuboLogger({
enableInProduction: true,
});🌍 Environment Behavior
- In non-production environments (
NODE_ENV !== 'production'): All logs are displayed. - In production environments (
NODE_ENV === 'production'): Logs are suppressed by default. - Override production suppression by passing
enableInProduction: trueto show logs.
🧪 Examples
Error Handling
try {
logger.green('Operation completed successfully.');
} catch (error) {
logger.red('Operation failed:', error.message);
}API Responses
const response = await fetch('/api/data');
if (response.ok) {
logger.green(`API call successful: ${response.status}`);
} else {
logger.red(`API call failed: ${response.status}`);
}Debug Information
logger.cyan('Debugging user flow:');
logger.blue(`Timestamp: ${new Date().toISOString()}`);🧪 Testing
npm test
npm run test:watch
npm run test:coverageNote:
npm run test:coveragewill fail if coverage thresholds are not met. Adjust thresholds injest.config.jsas needed.
🛠 Development
$ npm install
$ npm run dev
$ npm run build
$ npm run lint
$ npm run format📄 License
MIT © 3v69
🙌 Contributing
Contributions, issues, and feature requests are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the project
- 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
📈 Stats
❤️ Made with love by 3v69
