UNPKG

sassy-log

Version:

Logging, but with sass, satire, and some serious fun. A developer-first NPM package that replaces boring console.log() statements with snarky, sarcastic, or corporate-smooth one-liners.

406 lines (296 loc) β€’ 11 kB
# πŸ”₯ sassy-log **Logging, but with sass, satire, and some serious fun.** [![npm version](https://badge.fury.io/js/sassy-log.svg)](https://www.npmjs.com/package/sassy-log) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Node.js Compatible](https://img.shields.io/badge/node-%3E%3D12.0.0-brightgreen)](https://nodejs.org/) [![Cross Platform](https://img.shields.io/badge/platform-windows%20%7C%20macos%20%7C%20linux-lightgrey)](https://github.com/imankii01/sassy-log) > *Created with ❀️ by [imankii01](https://github.com/imankii01)* ## 🧠 What Is It? **sassy-log** is a developer-first NPM package that replaces boring `console.log()` statements with snarky, sarcastic, or corporate-smooth one-liners. It's a lightweight wrapper around your standard logging that adds humor and flavor to everyday logs β€” turning your terminal into a place of laughter, roast, and personality. Instead of this: ```javascript console.log("User created") ``` You get: ```javascript log.success("User created") // => "βœ… Well, well, look who can CRUD. | Original: 'User created'" ``` ## πŸ’‘ Why It Exists Developers spend hours staring at logs β€” but logs are often dry, robotic, or completely emotionless. **sassy-log** injects life into the debugging process by making logs feel like a teammate β€” whether that's a sarcastic senior dev, an overly positive intern, or a corporate manager sugarcoating a failure. This is more than just fun β€” it's: - **A morale booster** for dev teams - **A memory anchor** (you'll remember a funny log better) - **A great way to differentiate environments** (prod = corporate, dev = savage) - **Cross-platform compatible** (Windows, macOS, Linux, any terminal) ## πŸ“¦ Installation ```bash npm install sassy-log ``` Or with yarn: ```bash yarn add sassy-log ``` ## πŸš€ Quick Start ```javascript const sassyLogger = require('sassy-log'); // Create a logger with your preferred personality const log = sassyLogger({ mode: 'sarcastic' }); // Use it like console.log, but with personality log('Data fetched'); // => "πŸ’¬ Oh great, more data you don't know what to do with. | Original: 'Data fetched'" log.success('User updated'); // => "βœ… Well, would you look at that. It actually worked. | Original: 'User updated'" log.warn('API deprecated'); // => "⚠️ Oh look, a warning. I'm sure you'll totally pay attention to this one. | Original: 'API deprecated'" log.error('Server crashed'); // => "❌ Surprise! It's broken. Who could have seen this coming? | Original: 'Server crashed'" ``` ## 🎯 Core Modes | Mode | Personality | Example | |------|-------------|---------| | **savage** | Brutally honest dev-style roasts | *"Congrats. You broke it. Again."* | | **friendly** | Positive & cheerful | *"Oops! But you got this, champ πŸ’ͺ"* | | **sarcastic** | Passive-aggressive (default) | *"Oh wow, another null. Shocking."* | | **corporate** | Polite and professional | *"A minor disruption was observed during execution."* | ## πŸ› οΈ Advanced Usage ### Configuration Options ```javascript const log = sassyLogger({ mode: 'savage', // savage, friendly, sarcastic, corporate colors: true, // Enable/disable colors (auto-detected) timestamps: false, // Add timestamps to logs emojis: true, // Enable/disable emojis customQuotes: {} // Add your own quotes }); ``` ### Mode Switching at Runtime ```javascript const log = sassyLogger({ mode: 'friendly' }); log.info('Starting in friendly mode'); // => "😊 Hey there! Just keeping you in the loop!" log.setMode('savage'); log.info('Now in savage mode'); // => "πŸ’¬ Oh great, more data you don't know what to do with." // Check current mode console.log(log.getMode()); // => "savage" // See all available modes console.log(log.getAvailableModes()); // => ["savage", "friendly", "sarcastic", "corporate"] ``` ### Method Chaining ```javascript const log = sassyLogger({ mode: 'sarcastic' }); log .info('Starting process') .success('Step 1 complete') .warn('Step 2 has issues') .error('Process failed') .info('Retrying...'); ``` ### Custom Quotes ```javascript const log = sassyLogger({ mode: 'savage' }); // Add your own sassy quotes log.addCustomQuotes('savage', 'info', [ 'Oh look, another "temporary" solution that will last forever.', 'Breaking: Your code did something. Medal ceremony at 3 PM.' ]); log.info('Custom sass activated'); // => Might show one of your custom quotes! ``` ### Environment-Based Configuration ```javascript // Perfect for different environments const log = sassyLogger({ mode: process.env.NODE_ENV === 'production' ? 'corporate' : 'savage', colors: process.env.NODE_ENV !== 'production', timestamps: process.env.NODE_ENV === 'production' }); ``` ## 🌟 Platform Compatibility **sassy-log** works everywhere JavaScript runs: - βœ… **Node.js** (12.0.0+) - βœ… **Windows** (CMD, PowerShell, Windows Terminal) - βœ… **macOS** (Terminal, iTerm2) - βœ… **Linux** (Any terminal) - βœ… **CI/CD** (GitHub Actions, Travis, CircleCI, etc.) - βœ… **VS Code** integrated terminal - βœ… **Docker** containers - βœ… **Serverless** functions - βœ… **React/Next.js** (browser console) - βœ… **Electron** apps ### Color Support Colors are automatically detected and enabled when supported: - βœ… Modern terminals (supports 256+ colors) - βœ… VS Code, WebStorm, other IDEs - βœ… CI environments with color support - ❌ Plain text environments (automatically disabled) ## πŸ“Š API Reference ### Main Methods | Method | Description | Example | |--------|-------------|---------| | `log(msg?)` | Default info logging | `log('Hello')` | | `info(msg?)` | Information logging | `log.info('Process started')` | | `success(msg?)` | Success logging | `log.success('Task completed')` | | `warn(msg?)` | Warning logging | `log.warn('Memory high')` | | `error(msg?)` | Error logging | `log.error('Connection failed')` | ### Configuration Methods | Method | Description | Returns | |--------|-------------|---------| | `setMode(mode)` | Change logging mode | `SassyLogger` | | `getMode()` | Get current mode | `string` | | `getAvailableModes()` | List all modes | `string[]` | | `setColors(enabled)` | Toggle colors | `SassyLogger` | | `setTimestamps(enabled)` | Toggle timestamps | `SassyLogger` | | `setEmojis(enabled)` | Toggle emojis | `SassyLogger` | | `addCustomQuotes(mode, type, quotes)` | Add custom quotes | `SassyLogger` | ## 🎨 Examples in Action ### Express.js Middleware ```javascript const express = require('express'); const sassyLogger = require('sassy-log'); const app = express(); const log = sassyLogger({ mode: 'sarcastic', timestamps: true }); app.use((req, res, next) => { log.info(`${req.method} ${req.path}`); next(); }); app.get('/', (req, res) => { log.success('Home page served'); res.send('Hello World!'); }); app.listen(3000, () => { log.success('Server running on port 3000'); }); ``` ### CLI Tool ```javascript #!/usr/bin/env node const sassyLogger = require('sassy-log'); const log = sassyLogger({ mode: 'friendly', colors: true }); async function deploy() { log.info('Starting deployment...'); try { // Deployment logic here log.success('Deployment completed!'); } catch (error) { log.error('Deployment failed'); process.exit(1); } } deploy(); ``` ### React/Next.js (Browser) ```javascript import sassyLogger from 'sassy-log'; const log = sassyLogger({ mode: 'savage', colors: false, // Browser console handles colors differently emojis: true }); function MyComponent() { useEffect(() => { log.info('Component mounted'); return () => { log.warn('Component unmounting'); }; }, []); const handleClick = () => { log.success('Button clicked'); }; return <button onClick={handleClick}>Click me</button>; } ``` ## πŸ§ͺ Testing Run the built-in tests: ```bash # Basic functionality test npm test # See basic examples npm run example # See mode switching examples npm run example-modes ``` ## πŸ”§ TypeScript Support Full TypeScript support is included: ```typescript import sassyLogger, { SassyLoggerOptions, SassyLoggerInstance } from 'sassy-log'; const options: SassyLoggerOptions = { mode: 'savage', colors: true, timestamps: false, emojis: true }; const log: SassyLoggerInstance = sassyLogger(options); log.info('TypeScript works perfectly!'); ``` ## 🀝 Contributing We love contributions! Here's how you can help make **sassy-log** even more awesome: ### Adding New Quotes 1. Fork the repository 2. Edit `lib/quotes.js` 3. Add your hilarious quotes to any mode 4. Submit a pull request ### Adding New Modes Want to add a new personality mode? 1. Add your mode to `lib/quotes.js` 2. Update the TypeScript definitions 3. Add examples and tests 4. Submit a pull request ### Ideas for New Modes - `desi` - Indian developer humor - `gen-z` - Modern internet slang - `shakespearean` - Olde English style - `pirate` - Arrr, matey! - `motivational` - Life coach vibes ## πŸ“ˆ Use Cases - **Solo devs** who want logs that talk back - **Dev teams** using humorous logs in pull requests or Slack threads - **Startups** looking for playful internal tooling - **CLI tools** that want personality - **Internal dashboards** with fun notification logs - **Learning projects** to make coding more enjoyable - **Debugging sessions** that need some comic relief ## πŸ—ΊοΈ Roadmap - [ ] AI-powered roast generation using OpenAI/Gemini - [ ] Plugin system for custom modes - [ ] Log aggregation and analytics - [ ] Slack/Discord webhook integration - [ ] Voice output for the ultimate sass experience - [ ] Custom emoji sets - [ ] Log theming and styling options - [ ] Performance metrics integration ## πŸ“ License MIT Β© [imankii01](https://github.com/imankii01) ## πŸ™ Acknowledgments - Inspired by the need for more personality in developer tools - Built with love for the developer community - Thanks to all contributors and users who make this project awesome ## πŸ“ž Connect with the Creator - **GitHub**: [@imankii01](https://github.com/imankii01) - **NPM**: [@imankii01](https://www.npmjs.com/~imankii01) - **Issues**: [Report bugs or request features](https://github.com/imankii01/sassy-log/issues) --- **Made with ❀️ and a lot of sass by [imankii01](https://github.com/imankii01)** *Because debugging should be fun, not frustrating!* πŸŽ‰ ## πŸ“‹ Quick Reference ```javascript // Basic usage const log = require('sassy-log')(); // All methods log('info message'); log.info('info message'); log.success('success message'); log.warn('warning message'); log.error('error message'); // Configuration log.setMode('savage'); log.setColors(true); log.setTimestamps(true); log.setEmojis(false); // Custom quotes log.addCustomQuotes('savage', 'info', ['Your custom sass here']); // Chaining log.info('start').success('middle').error('end'); ``` Now go forth and log with sass! πŸ”₯# sassy-log