sar-logger
v1.1.7
Published
A lightweight TypeScript logger that adds colorful, time, and prefixed messages to your Node.js and web console.
Maintainers
Readme
sar-logger
A lightweight TypeScript logger that adds colorful, time, and prefixed messages to your Node.js and web console.
✨ Features
- 🎨 Color-coded log levels
- ⏱ Auto-time output
- 🏷 Optional log prefix (e.g.
[API]) - 📁 Optional file logging (coming soon)
- 🪶 Lightweight — no external dependencies
📦 Install
Install via npm or yarn:
npm install -D sar-loggeror
yarn add -D sar-logger🚀 Usage
import { logger, setLoggerPrefix } from 'sar-logger';
// Set a custom label prefix
setLoggerPrefix('SERVER');
// Show timestamp
enableTime(true)
// Log examples
logger.success('Server started successfully!');
logger.info('Listening on port 3000');
logger.warning('Memory usage is high');
logger.error('Failed to connect to database');
logger.debug('Debugging request:', { id: 42 });
logger.fatal('Unexpected shutdown occurred.');
// Custom color
logger.custom('Custom color', { color: '#FF5733' });
🖨 Sample Output
Web Output:
Terminal Output:
Show time Output:
File Output (log.txt): (coming soon)
⚙️ API
Set a global prefix (like [API] or [DB]).
setLoggerPrefix(name: string)Show time in log [HH:MM:SS]
enableTime(enabled: boolean)📜 License
MIT © 2025 lavisar Feel free to contribute!
