Skip to main content

Quick Start

Get beautiful logs in under 2 minutes. This guide covers the most common use cases.

Basic Usage

Import and Use

import log from 'logluxe';

// Semantic logging - each level has its own color and icon
log.success('Operation completed'); // ✔ green
log.error('Something went wrong'); // ✖ red
log.warn('Deprecated feature'); // ⚠ yellow
log.info('Server started'); // ℹ cyan
log.debug('Variable value:', data); // ● gray
Console
Operation completed
Something went wrong
Deprecated feature
Server started
Variable value: { id: 1, name: "test" }
🎮 Try it yourself

Logging with Data

Pass any number of arguments - objects are automatically formatted:

// Log with additional data
log.info('User logged in', { userId: 123, role: 'admin' });

// Log multiple values
log.debug('Processing', 'item1', 'item2', 'item3');

// Objects are pretty-printed with syntax highlighting
log.info('Config loaded', {
database: { host: 'localhost', port: 5432 },
cache: { enabled: true, ttl: 3600 }
});
Output
User logged in { "userId": 123, "role": "admin" }
Processing item1 item2 item3
Config loaded
{ "database": { "host": "localhost", "port": 5432 }, "cache": { "enabled": true, "ttl": 3600 } }
🎮 Try it yourself

Error Logging

Errors get special formatting with stack traces:

try {
throw new Error('Database connection failed');
} catch (error) {
log.error('Failed to connect', error);
}
Output
Failed to connect
Error: Database connection failed at connect (database.ts:42:11) at main (index.ts:15:3)
🎮 Try it yourself

Quick Styling

Manual Colors

// Use any named color
log.color('Custom message', 'red');
log.color('Another message', 'cyan');

// Use HEX colors
log.color('Branded text', '#ff6b6b');

// Use RGB
log.color('RGB color', 'rgb(100, 200, 50)');
Color Output
Custom message
Another message
Branded text
RGB color
🎮 Try Colors

Inline Color Tags

// Mix colors in a single message
log.tagged('[red]ERROR[/red] File not found');
log.tagged('Status: [green]ONLINE[/green]');
log.tagged('[cyan]User:[/cyan] [yellow]John[/yellow] logged in');
Tagged Output
ERROR File not found
Status: ONLINE
User: John logged in
🎮 Try Tagged Output

Chainable Styles

// Build complex styles with method chaining
log.paint('CRITICAL ALERT')
.white()
.bgRed()
.bold()
.print();

log.paint('Subtle note')
.gray()
.italic()
.print();
Output
CRITICAL ALERT
Subtle note

Text Effects

// Rainbow text - each character a different color
log.rainbow('Hello World!');

// Gradient text - smooth color transitions
log.gradient('Welcome to the app!');

// Neon glow effect
log.neon('SERVER ONLINE', '#00ff00');
Effects Output
HelloWorld!
Welcome to the app!
SERVER ONLINE
🎮 Try Effects

Performance Tracking

// Time synchronous operations
const result = log.perf('Database query', () => {
return db.query('SELECT * FROM users');
});

// Time async operations
const data = await log.perf('API fetch', async () => {
return fetch('/api/data').then(r => r.json());
});
Output
Database query took 42.5ms
API fetch took 120.3ms

Log Grouping

log.group('User Registration');
log.info('Validating email...');
log.info('Checking username...');
log.success('User created!');
log.end();
Output
User Registration
Validating email...
Checking username...
User created!
🎮 Try Grouping

Configuration

// Disable colors (useful for CI or file logging)
log.noColor();

// Mute all output
log.mute();
log.unmute();

// Change theme
log.setTheme('neon'); // 'default' | 'dark' | 'minimal' | 'neon'

// Enable labels
log.configure({ labels: true });
log.info('With label'); // INFO ℹ With label
Output
[INFO] With label

Complete Example

Here's a realistic example combining multiple features:

import log from 'logluxe';

// Application startup
log.banner('My Awesome App v1.0.0');

log.group('Initialization');
log.info('Loading configuration...');
log.success('Config loaded');

log.info('Connecting to database...');
const db = await log.perf('DB Connection', async () => {
return connectToDatabase();
});
log.success('Database connected');
log.end();

// Runtime logging
log.info('Server starting on port', { port: 3000 });
log.success('Server ready!');
Application Startup
┌─────────────────────────────────┐
│ My Awesome App v1.0.0 │
└─────────────────────────────────┘
Initialization
Loading configuration...
Config loaded
Connecting to database...
DB Connection took 85.2ms
Database connected
Server starting on port { "port": 3000 }
Server ready!
🎮 Try Complete Example

Next: Console Patch - Zero-change integration →