A lightweight Node.js logging utility with color, icons support, time formatting, file logging capabilities, and customizable icon themes.
- 🎨 Color-coded logs for different log levels
- ⏰ Automatic timestamp with GMT+7 timezone by default
- 📁 File logging with automatic directory creation
- 🔧 Development mode filtering
- 🏗️ Singleton pattern for consistent logging across your app
- 🎭 10 Icon themes for visual customization
npm install andb-logger
const logger = require('andb-logger').getInstance({
mode: 'development',
dirpath: __dirname,
logName: 'MYAPP',
theme: 'emoji' // Choose your icon theme
});
logger.info('Server started on port 3000');
logger.error('Database connection failed');
logger.warn('Deprecated API called');
logger.dev('Debug info - only shown in dev mode');
AndbLogger comes with 10 pre-built icon themes to make your logs more visual and intuitive:
Traditional logging icons - clean and professional
Expressive emoji icons - colorful and fun
Simple ASCII symbols - lightweight and universal
Expressive face emojis - emotional and relatable
Directional arrow icons - modern and sleek
Other themes include:
- Circles - Circular indicators (minimal and clean)
- Squares - Square block icons (geometric and structured)
- Tech - Technology-focused icons (perfect for dev environments)
- Nature - Natural element icons (organic and calming)
- Minimal - Single letter indicators (ultra-minimal and fast)
const logger = require('andb-logger').getInstance({
theme: 'tech' // Use tech theme
});
logger.setTheme('emoji'); // Switch to emoji theme
logger.setTheme('minimal'); // Switch to minimal theme
Classic Theme (Default):
ℹ️ MYAPP-INFO - 20/01/2024 10:31:08 > Server started
❌ MYAPP-ERROR - 20/01/2024 10:31:08 > Connection failed
⚠️ MYAPP-WARNING - 20/01/2024 10:31:08 > Deprecated API
🔧 MYAPP-DEV - 20/01/2024 10:31:08 > Debug info
Tech Theme:
💻 MYAPP-INFO - 20/01/2024 10:31:08 > Server started
🔥 MYAPP-ERROR - 20/01/2024 10:31:08 > Connection failed
⚡ MYAPP-WARNING - 20/01/2024 10:31:08 > Deprecated API
🔧 MYAPP-DEV - 20/01/2024 10:31:08 > Debug info
Minimal Theme:
i MYAPP-INFO - 20/01/2024 10:31:08 > Server started
e MYAPP-ERROR - 20/01/2024 10:31:08 > Connection failed
w MYAPP-WARNING - 20/01/2024 10:31:08 > Deprecated API
d MYAPP-DEV - 20/01/2024 10:31:08 > Debug info
const logger = require('andb-logger').getInstance({
mode: 'production', // 'production' | 'development' | 'dev'
dirpath: __dirname, // Directory for log files
logName: 'logger', // Logger name prefix
theme: 'classic' // Icon theme (default: 'classic')
});
Log info level messages (cyan color)
logger.info('User logged in', { userId: 123 });
// logger-INFO - 20/01/2024 10:31:08 > User logged in { userId: 123 }
Log error level messages (red color)
logger.error('Database connection failed', error);
// logger-ERROR - 20/01/2024 10:31:08 > Database connection failed Error: ...
Log warning level messages (yellow color)
logger.warn('Deprecated method called');
// logger-WARNING - 20/01/2024 10:31:08 > Deprecated method called
Log development messages (magenta color) - only shown in development mode
logger.dev('Debug info', { requestId: 'abc123' });
// logger-DEV - 20/01/2024 10:31:08 > Debug info { requestId: 'abc123' }
Change the icon theme dynamically
logger.setTheme('emoji'); // Switch to emoji theme
logger.setTheme('tech'); // Switch to tech theme
Write log to file
logger.write('Custom log message', 'api');
// Creates: logs/api-DESKTOP-F2RK900-20-1-2024.log
Parameters:
text
(string): Text to writefilename
(string, optional): File name prefix (default: 'combined')
const logger = require('andb-logger').getInstance({
theme: 'faces' // Use expressive face icons
});
logger.info('Application started'); // 😊
logger.error('Something went wrong'); // 😱
logger.warn('This feature is deprecated'); // 😰
logger.dev('Debug information'); // 🤔
const logger = require('andb-logger').getInstance();
// Start with classic theme
logger.info('Server starting...');
// Switch to tech theme for development
logger.setTheme('tech');
logger.dev('Debug mode enabled');
// Switch to minimal for production
logger.setTheme('minimal');
logger.info('Server ready');
const logger = require('andb-logger').getInstance({
mode: process.env.NODE_ENV,
theme: process.env.NODE_ENV === 'development' ? 'emoji' : 'minimal'
});
Log files are created in the logs/
directory with the following naming pattern:
{filename}-{hostname}-{day}-{month}-{year}.log
Example: combined-DESKTOP-F2RK900-20-1-2024.log
AndbLogger supports flexible timezone configuration to ensure accurate timestamps in your logs. By default, it uses GMT+7, but you can customize it
MIT