consola

Elegant console logger for JavaScript and Node.js — beautiful formatting, log levels, reporters, and minimal bundle size.

consola

General JS

Elegant console logger for JavaScript and Node.js — beautiful formatting, log levels, reporters, and minimal bundle size.

Fit

Bundle (gzip)

2.5 kB

6.3 kB raw

Install size includes transitive dependencies. Bundle size is gzipped browser payload.

Freshness

The Problem

console.log provides no log levels, no structured output, and no way to suppress debug messages in production. Custom loggers need consistent formatting across development (pretty) and production (JSON) environments.

What It Does

Consola provides tagged log methods (info, success, warn, error, debug, trace), colorized terminal output with icons, and configurable reporters. In CI/testing, it detects the environment and switches formats. A mockConsola utility captures output in tests without polluting stdout.

Installation

bash
npm install consola

Usage Example

typescript
import { consola, createConsola } from 'consola';

// Use the default instance
consola.info('Server starting...');
consola.success('Connected to database');
consola.warn('API rate limit approaching');
consola.error('Payment failed', { orderId: '123', reason: 'card_declined' });

// Scoped logger for a module
const logger = createConsola().withTag('auth');
logger.debug('Verifying token');  // [auth] Verifying token

// Set log level (suppress debug in production)
consola.level = process.env.NODE_ENV === 'production' ? 3 : 5;

Related packages