@ru-dr/plip v1.1.0
๐ซง Plip Logger
A delightful, colorful logging experience for modern Node.js applications
Installation โข Quick Start โข Documentation โข Examples โข Contributing
โจ Why Plip?
Tired of boring console logs? Plip brings joy back to logging with:
- ๐ Smart Colors - Automatic terminal detection with beautiful color schemes
- ๐ Expressive Emojis - Visual context that makes logs easier to scan
- ๐ฏ 7 Log Levels - From
verbosetoerror, perfect granularity - ๐ Syntax Highlighting - JSON objects rendered beautifully
- โ๏ธ Fluent API - Chain methods for elegant configuration
- ๐ Zero Config - Works great out of the box, CSR by default
- ๐ SSR/CSR Optimized - Specialized configs for server and client environments
- ๐ฆ TypeScript First - Full type safety and IntelliSense
- ๐ง Environment Aware - Respects
NODE_ENVand terminal capabilities
๐ฆ Installation
::: code-group
$ npm install @ru-dr/plip$ yarn add @ru-dr/plip$ pnpm add @ru-dr/plip$ bun add @ru-dr/plip:::
๐ Multi-Language Support Coming Soon!
Plip is currently available for JavaScript/TypeScript environments. We're actively working on bringing the same delightful logging experience to Python, Java, PHP, and other popular languages. Follow our progress or contribute to help us expand faster!
๐ Quick Start
Get logging in seconds:
import { plip } from '@ru-dr/plip';
plip.info("๐ Welcome to Plip!");
plip.success("โ
Everything is working perfectly");
plip.warn("โ ๏ธ This might need your attention");
plip.error("๐ฅ Something went wrong");
// Log complex objects with beautiful syntax highlighting
plip.info("User profile:", {
name: "Alex Developer",
age: 28,
skills: ["TypeScript", "Node.js", "React"],
active: true
});Output Preview:
๐ซง [INFO] ๐ Welcome to Plip!
๐ [SUCCESS] โ
Everything is working perfectly
โ ๏ธ [WARN] โ ๏ธ This might need your attention
๐ฅ [ERROR] ๐ฅ Something went wrong
๐ซง [INFO] User profile: {
"name": "Alex Developer",
"age": 28,
"skills": ["TypeScript", "Node.js", "React"],
"active": true
}๐ API Documentation
Creating Logger Instances
import { plip, createPlip } from '@ru-dr/plip';
// Use the default logger (recommended for most cases)
plip.info("Using default logger");
// Create a custom logger with specific configuration
const customLogger = createPlip({
enableEmojis: true,
enableColors: true,
enabledLevels: ['info', 'warn', 'error']
});
// Create a production logger
const prodLogger = createPlip({
enableEmojis: false,
enableColors: false,
enabledLevels: ['warn', 'error']
});๐จ Log Levels
Plip provides 7 distinct log levels, each with its own emoji and color:
| Level | Emoji | Description | Use Case |
|---|---|---|---|
info | ๐ซง | General information | App status, user actions |
success | ๐ | Success messages | Completed operations |
warn | โ ๏ธ | Warning messages | Deprecated features, recoverable errors |
error | ๐ฅ | Error messages | Exceptions, failures |
debug | ๐ | Debug information | Development debugging |
trace | ๐ฐ๏ธ | Detailed tracing | Performance monitoring |
verbose | ๐ข | Verbose output | Detailed system information |
// Using all log levels
plip.info("Application started successfully");
plip.success("User authenticated");
plip.warn("API rate limit approaching");
plip.error("Database connection failed");
plip.debug("Processing user request", { userId: 123 });
plip.trace("Function execution time: 45ms");
plip.verbose("System memory usage:", process.memoryUsage());โ๏ธ Configuration Options
Customize Plip to fit your needs:
| Option | Type | Default | Description |
|---|---|---|---|
silent | boolean | false | Suppress all output |
enableEmojis | boolean | auto-detect | Show emoji indicators |
enableColors | boolean | auto-detect | Use colorized output |
enableSyntaxHighlighting | boolean | true | Highlight object syntax |
devOnly | boolean | auto-detect | Only log in development |
enabledLevels | LogLevel[] | all | Array of levels to enable |
theme | Partial<PlipTheme> | default | Custom colors and emojis |
const logger = createPlip({
silent: false,
enableEmojis: true,
enableColors: true,
enableSyntaxHighlighting: true,
devOnly: false,
enabledLevels: ['info', 'warn', 'error', 'success'],
theme: {
emojis: {
info: "โน๏ธ",
success: "โ
"
},
colors: {
info: customBlueColor,
success: customGreenColor
}
}
});๐ Fluent API (Method Chaining)
Build your perfect logger with our fluent, chainable API:
const logger = plip
.withColors(true) // Enable colors
.withEmojis(true) // Enable emojis
.withSyntaxHighlighting(true) // Enable JSON highlighting
.levels('info', 'error', 'success') // Only these levels
.silent(); // Make it silent
// Each method returns a new logger instance
const devLogger = plip.levels('debug', 'trace', 'verbose');
const prodLogger = plip.levels('warn', 'error').withEmojis(false);Available Fluent Methods:
.withColors(enabled)- Toggle color output.withEmojis(enabled)- Toggle emoji indicators.withSyntaxHighlighting(enabled)- Toggle object highlighting.withTheme(theme)- Apply custom theme.withContext(context)- Add persistent context to all logs.levels(...levels)- Filter enabled log levels.silent()- Suppress all output
๐ก Examples
Basic Logging
import { plip } from '@ru-dr/plip';
// Simple messages
plip.info("Server starting on port 3000");
plip.success("Database connected successfully");
// With data
plip.info("New user registered:", { email: "user@example.com", id: 123 });
plip.error("Authentication failed:", { reason: "invalid_token", userId: 456 });Context-Aware Logging
import { plip } from '@ru-dr/plip';
// Create context-aware loggers for different scopes
const authLogger = plip.withContext({ scope: "auth" });
const dbLogger = plip.withContext({ scope: "database", pool: "primary" });
const apiLogger = plip.withContext({ scope: "api", version: "v1" });
// All logs will include the context automatically
authLogger.info("User login attempt", { userId: 123, method: "oauth" });
// Output: ๐ซง [INFO] User login attempt {"scope":"auth","userId":123,"method":"oauth"}
dbLogger.warn("Connection pool high usage", { activeConnections: 45 });
// Output: โ ๏ธ [WARN] Connection pool high usage {"scope":"database","pool":"primary","activeConnections":45}
// Context can be chained and extended
const requestLogger = apiLogger.withContext({ requestId: "req-789" });
requestLogger.error("Request processing failed", { endpoint: "/users" });
// Output: ๐ฅ [ERROR] Request processing failed {"scope":"api","version":"v1","requestId":"req-789","endpoint":"/users"}Environment-Specific Logging
import { createPlip } from '@ru-dr/plip';
// Development logger - verbose and colorful
const devLogger = createPlip({
enabledLevels: ['debug', 'trace', 'info', 'warn', 'error'],
enableEmojis: true,
enableColors: true
});
// Production logger - errors and warnings only
const prodLogger = createPlip({
enabledLevels: ['warn', 'error'],
enableEmojis: false,
enableColors: false,
enableSyntaxHighlighting: false
});
// Use based on environment
const logger = process.env.NODE_ENV === 'production' ? prodLogger : devLogger;Custom Themes
import { createPlip, colors } from '@ru-dr/plip';
const logger = createPlip({
theme: {
emojis: {
info: "๐",
success: "โ
",
warn: "โ ๏ธ",
error: "โ"
},
colors: {
info: colors.blue,
success: colors.green,
warn: colors.yellow,
error: colors.red
}
}
});Conditional Logging
import { createPlip } from '@ru-dr/plip';
// Only log in development
const debugLogger = createPlip({
devOnly: true,
enabledLevels: ['debug', 'trace']
});
// Log everything except in production
const logger = createPlip({
enabledLevels: process.env.NODE_ENV === 'production'
? ['warn', 'error']
: ['debug', 'info', 'warn', 'error']
});๐ SSR vs CSR Logging
Plip provides optimized configurations for both Server-Side Rendering (SSR) and Client-Side Rendering (CSR) environments. CSR is the default for the best modern web development experience.
Quick Usage
import { plip, createSSRLogger, createCSRLogger } from '@ru-dr/plip';
// Default logger uses CSR configuration (with emojis & colors)
plip.info("Hello world!"); // ๐ซง [INFO] Hello world!
// Explicit SSR logger (optimized for servers)
const serverLogger = createSSRLogger();
serverLogger.info("Server started", { port: 3000 });
// Output: [INFO] Server started {"port":3000}
// Explicit CSR logger (optimized for browsers)
const clientLogger = createCSRLogger();
clientLogger.success("User logged in", { userId: 123 });
// Output: ๐ [SUCCESS] User logged in {"userId":123}Key Differences
| Feature | SSR (Server) | CSR (Client) |
|---|---|---|
| Emojis | โ Disabled | โ Enabled |
| Colors | โ Disabled | โ Enabled |
| Syntax Highlighting | โ Disabled | โ Enabled |
| Best For | APIs, servers, logs | Browsers, debugging |
| Output Style | Structured, plain | Rich, visual |
Framework Examples
// Next.js API Route (SSR)
import { createSSRLogger } from '@ru-dr/plip';
const serverLogger = createSSRLogger();
export default function handler(req, res) {
serverLogger.info("API request", { method: req.method, url: req.url });
}
// React Component (CSR)
import { createCSRLogger } from '@ru-dr/plip';
const clientLogger = createCSRLogger();
function App() {
useEffect(() => {
clientLogger.success("App loaded"); // ๐ [SUCCESS] App loaded
}, []);
}๐ Learn More: Check out our SSR vs CSR Guide for detailed examples and best practices.
import { createPlip } from '@ru-dr/plip';
// Only log in development const debugLogger = createPlip({ devOnly: true });
// Custom conditions const logger = createPlip({ enabledLevels: process.env.DEBUG ? 'debug', 'trace', 'info', 'warn', 'error' : 'warn', 'error' });
## ๐ ๏ธ Advanced Usage
### TypeScript Integration
```typescript
import { PlipConfig, LogLevel, createPlip } from '@ru-dr/plip';
// Type-safe configuration
const config: PlipConfig = {
enabledLevels: ['info', 'error'] as LogLevel[],
enableColors: true,
theme: {
emojis: {
info: "๐ก",
error: "๐จ"
}
}
};
const logger = createPlip(config);Framework Integration
Express.js Middleware
import express from 'express';
import { createPlip } from '@ru-dr/plip';
const logger = createPlip();
const app = express();
app.use((req, res, next) => {
logger.info(`${req.method} ${req.path}`, {
ip: req.ip,
userAgent: req.get('User-Agent')
});
next();
});Error Handling
import { createPlip } from '@ru-dr/plip';
const logger = createPlip();
process.on('uncaughtException', (error) => {
logger.error('Uncaught Exception:', {
message: error.message,
stack: error.stack,
timestamp: new Date().toISOString()
});
process.exit(1);
});
try {
// Your application logic
} catch (error) {
logger.error('Application error:', error);
}๐ Learn More
Explore our comprehensive documentation to master Plip Logger:
๐ Guides
- Basic Usage - Learn the fundamentals
- Configuration - Customize Plip to your needs
- SSR vs CSR - Server-side and client-side optimized configurations
- Best Practices - Write better logs
๐ก Examples & Patterns
- Custom Loggers - Context-aware logging and advanced patterns
- Integration Examples - Framework-specific implementations
- Production Setup - Production-ready configurations
- SSR/CSR Quick Start - Get started with server/client logging
๐ง Integrations
- Express.js - Express middleware and patterns
- Next.js - Next.js SSR/CSR integration
- NestJS - NestJS dependency injection
- Database Logging - Database query logging
๐ API Reference
- Logger API - Complete method reference
- Configuration - All configuration options
- Types - TypeScript definitions
๐ก Pro Tip: Start with Custom Loggers to learn context-aware logging with
plip.withContext({ scope: "auth" })
๐ค Contributing
We love contributions! Here's how you can help make Plip even better:
๐ Found a Bug?
- Check if it's already reported in Issues
- If not, create a new issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Your environment details
๐ก Have an Idea?
- Open a feature request
- Join our discussions
- Check our roadmap for planned features
๐ง Want to Code?
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/plip.git - Create a branch:
git checkout -b feature/amazing-feature - Install dependencies:
bun install - Make your changes
- Test your changes:
bun test - Build the project:
bun run build - Commit your changes:
git commit -m 'Add amazing feature' - Push to your branch:
git push origin feature/amazing-feature - Open a Pull Request
๐ Development Setup
# Clone the repository
git clone https://github.com/ru-dr/plip.git
cd plip
# Install dependencies
bun install
# Run tests
bun test
# Run tests in watch mode
bun test --watch
# Build the project
bun run build
# Test your changes
bun run dev๐งช Testing
We use Bun for testing. Please ensure:
- All tests pass:
bun test - Add tests for new features
- Maintain or improve code coverage
- Follow existing test patterns
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
TL;DR: You can use, modify, and distribute this project freely. Just keep the copyright notice! ๐
Made with โค๏ธ by ru-dr
โญ Star this repo if you find it useful! โญ
Report Bug โข Request Feature โข Discussions