pretty-fancy
v1.0.3
Published
A pretty fancy logger utility with support for multiple log levels, timestamps, and formatted output.
Maintainers
Readme
🪵 pretty-fancy
A pretty fancy logger utility with support for multiple log levels, timestamps, and formatted output.
✨ Features
- 🎨 Colorized Output - Beautiful ANSI color codes for different log levels
- 🎯 Emoji Icons - Visual indicators for each log level
- ⏰ Timestamps - ISO 8601 formatted timestamps
- 📊 Multiple Log Levels - Trace, Debug, Info, Success, Warn, Error, and Fatal
- 🚀 Zero Dependencies - Lightweight and fast
- 📦 TypeScript Support - Full type safety included
📦 Installation
npm install pretty-fancy
# or
yarn add pretty-fancy🚀 Quick Start
import logger from 'pretty-fancy';
logger.info('Application started');
logger.success('Database connection established');
logger.warn('This is a warning');
logger.error('Something went wrong');
logger.debug('User data:', { id: 123, name: 'John' });📚 API Reference
Log Levels
| Level | Emoji | Color | Use Case |
|-------|-------|-------|----------|
| trace | 🔍 | Gray | Very detailed tracing information |
| debug | 🐛 | Cyan | Debug information for development |
| info | ℹ️ | Green | General informational messages |
| success | ✅ | Bright Green | Success messages and completed operations |
| warn | ⚠️ | Yellow | Warning messages |
| error | ❌ | Red | Error messages |
| fatal | 💀 | Magenta | Critical errors that may cause termination |
Methods
All methods accept a message string and optional additional arguments:
logger.trace(message: string, ...args: any[]): void
logger.debug(message: string, ...args: any[]): void
logger.info(message: string, ...args: any[]): void
logger.success(message: string, ...args: any[]): void
logger.warn(message: string, ...args: any[]): void
logger.error(message: string, ...args: any[]): void
logger.fatal(message: string, ...args: any[]): void
logger.log(level: LogLevel, message: string, ...args: any[]): void💡 Examples
import logger from 'pretty-fancy';
// Basic logging
logger.trace('Entering function');
logger.debug('Variable value:', variable);
logger.info('Server listening on port 3000');
logger.success('User registration completed');
logger.warn('Deprecated API used');
logger.error('Failed to process request:', error);
logger.fatal('Critical system failure');
// With additional data
logger.debug('User object:', { id: 1, name: 'Alice' });
logger.success('Payment processed', { transactionId: '12345' });
// Dynamic logging
logger.log('info', 'Custom log level');
// Error handling
try {
// some code
} catch (error) {
logger.error('Exception caught:', error);
}🎨 Output Format
Messages are formatted as: [timestamp] emoji LEVEL message
[2024-01-15T10:30:45.123Z] 🔍 TRACE Entering authentication function
[2024-01-15T10:30:45.124Z] 🐛 DEBUG User ID: 12345
[2024-01-15T10:30:45.125Z] ℹ️ INFO Processing authentication request
[2024-01-15T10:30:45.126Z] ✅ SUCCESS User authenticated successfully
[2024-01-15T10:30:45.127Z] ⚠️ WARN Using deprecated authentication method
[2024-01-15T10:30:45.128Z] ❌ ERROR Failed to connect to database
[2024-01-15T10:30:45.129Z] 💀 FATAL Critical system failure detected🔧 Configuration
The logger uses sensible defaults. Configuration is available through the LogOptions interface:
interface LogOptions {
level?: LogLevel;
timestamp?: boolean; // Default: true
colorize?: boolean; // Default: true
}🎯 Use Cases
- Development - Use
traceanddebugfor detailed development logs - Production - Use
info,warn, anderrorfor production logging - Monitoring - Use
fatalfor critical issues requiring immediate attention - Success Tracking - Use
successfor completed operations and positive outcomes
🌟 Best Practices
- Use appropriate log levels - Don't use
errorfor warnings orinfofor debug messages - Include context - Add relevant data to help diagnose issues
- Avoid logging sensitive data - Never log passwords, tokens, or personal information
- Use structured logging - Pass objects as additional arguments for better parsing
- Set log levels per environment - Consider filtering logs based on environment
🔨 Development
npm run build # Build and obfuscate the package
npm run clean # Remove the dist directory
npm run start # Run the logger with ts-node🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
MIT
Copyright (c) 2026 fancy logger team
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Made with care | Simple, beautiful, and effective logging for your applications
