Skip to main content

Migration Guide

Migrate from other logging libraries to Logluxe with minimal effort.

From console.log

One-Line Migration

The easiest migration - just import the patch:

// Before: No changes needed to existing code
console.log('Hello');
console.error('Error');

// After: Add one line at the top of your entry file
import 'logluxe/patch';

// Your existing console.* calls now have colors and formatting!
console.log('Hello'); // Now styled!
console.error('Error'); // Now red!
After Patch Import
ℹ Hello
✖ Error
(Same code, now with colors!)

Manual Migration

For more control, replace console calls with log methods:

// Before
console.log('Info message');
console.error('Error:', error);
console.warn('Warning');
console.debug('Debug info');

// After
import { log } from 'logluxe';

log.info('Info message');
log.error('Error:', error);
log.warn('Warning');
log.debug('Debug info');
Manual Migration
ℹ Info message
✖ Error: Something went wrong
⚠ Warning
● Debug info
🎮 Try Migrated Code

From chalk

Basic Colors

// Before (chalk)
import chalk from 'chalk';
console.log(chalk.red('Error'));
console.log(chalk.green.bold('Success'));
console.log(chalk.bgYellow.black('Warning'));

// After (logluxe)
import { log } from 'logluxe';
log.color('Error', 'red');
log.paint('Success').green().bold().print();
log.paint('Warning').black().bgYellow().print();
Chalk Migration
Error
Success
Warning

Chaining

// Before (chalk)
console.log(chalk.red.bold.underline('Important'));

// After (logluxe)
log.paint('Important').red().bold().underline().print();

Template Literals

// Before (chalk)
console.log(`Status: ${chalk.green('OK')} Items: ${chalk.yellow(count)}`);

// After (logluxe)
console.log(`Status: ${log.color('OK', 'green')} Items: ${log.color(count, 'yellow')}`);

// Or use tagged strings
log.tagged('Status: [green]OK[/green] Items: [yellow]42[/yellow]');
Template Literals
Status: OK Items: 42

From winston

Basic Setup

// Before (winston)
import winston from 'winston';

const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.colorize(),
winston.format.simple()
),
transports: [
new winston.transports.Console()
]
});

logger.info('Hello');
logger.error('Error');

// After (logluxe)
import { createLogger } from 'logluxe';

const log = createLogger({
level: 'info',
timestamp: true
});

log.info('Hello');
log.error('Error');
Winston Migration
[2024-01-15T10:30:45.123Z]
ℹ Hello
[2024-01-15T10:30:45.456Z]
✖ Error

Log Levels

// Before (winston)
logger.error('Error message');
logger.warn('Warning message');
logger.info('Info message');
logger.debug('Debug message');

// After (logluxe) - same API!
log.error('Error message');
log.warn('Warning message');
log.info('Info message');
log.debug('Debug message');

Child Loggers

// Before (winston)
const childLogger = logger.child({ service: 'users' });
childLogger.info('User created');

// After (logluxe)
const childLog = log.child({ prefix: 'users' });
childLog.info('User created');
Child Loggers
[users]
ℹ User created

From pino

Basic Usage

// Before (pino)
import pino from 'pino';

const logger = pino({
level: 'info',
transport: {
target: 'pino-pretty'
}
});

logger.info('Hello');
logger.info({ user: 'john' }, 'User logged in');

// After (logluxe)
import { createLogger } from 'logluxe';

const log = createLogger({
level: 'info'
});

log.info('Hello');
log.info('User logged in', { user: 'john' });

JSON Logging

// Before (pino)
const logger = pino(); // JSON by default

// After (logluxe)
const log = createLogger({
format: 'json' // For production
});
JSON Format
{"level":"info","message":"Hello","timestamp":"2024-01-15T10:30:45.123Z"}
{"level":"info","message":"User logged in","user":"john","timestamp":"..."}

From debug

Basic Usage

// Before (debug)
import createDebug from 'debug';
const debug = createDebug('app:server');

debug('Server starting...');

// After (logluxe)
import { createLogger } from 'logluxe';
const log = createLogger({ prefix: 'app:server' });

log.debug('Server starting...');
Debug Migration
[app:server]
● Server starting...

Namespaced Debugging

// Before (debug)
const dbDebug = createDebug('app:db');
const httpDebug = createDebug('app:http');

dbDebug('Query executed');
httpDebug('Request received');

// After (logluxe)
const dbLog = createLogger({ prefix: 'app:db' });
const httpLog = createLogger({ prefix: 'app:http' });

dbLog.debug('Query executed');
httpLog.debug('Request received');
Namespaced Loggers
[app:db]
● Query executed
[app:http]
● Request received

From consola

Basic Usage

// Before (consola)
import consola from 'consola';

consola.info('Info');
consola.success('Success');
consola.error('Error');
consola.warn('Warning');

// After (logluxe) - same method names!
import { log } from 'logluxe';

log.info('Info');
log.success('Success');
log.error('Error');
log.warn('Warning');

Boxed Messages

// Before (consola)
consola.box('Important message');

// After (logluxe)
log.banner('Important message');
Banner/Box
╔══════════════════════════════╗
║ Important message ║
╚══════════════════════════════╝
🎮 Try Banner

From signale

Basic Usage

// Before (signale)
import { Signale } from 'signale';
const signale = new Signale();

signale.success('Operation successful');
signale.error('Something went wrong');
signale.await('Loading...');

// After (logluxe)
import { log } from 'logluxe';

log.success('Operation successful');
log.error('Something went wrong');
log.info('Loading...');
Signale Migration
✔ Operation successful
✖ Something went wrong
ℹ Loading...

Feature Mapping

Featureconsolechalkwinstonpinologluxe
Colors✗*
Log levels
Timestamps
JSON output
Zero deps
TypeScript
Browser
Gradients
Perf timing
Grouping
Themes
Inline tags

* pino requires pino-pretty for colors

Tips for Smooth Migration

1. Start with the Patch

// Easiest first step
import 'logluxe/patch';
// All existing console.* calls work with colors

2. Migrate Gradually

// Keep old code working while migrating
import { log } from 'logluxe';

// Old code still works
console.log('Old code');

// New code uses logluxe
log.info('New code');

3. Search and Replace

Common replacements:

  • console.log(log.info(
  • console.error(log.error(
  • console.warn(log.warn(
  • chalk.red(log.color(, 'red')

4. Update Configuration

// Consolidate logging config
// config/logger.ts
export const log = createLogger({
// All options in one place
});

// Import everywhere
import { log } from './config/logger';

Ready to get started? Check the Quick Start Guide!