consola
Elegant console logger for JavaScript and Node.js — beautiful formatting, log levels, reporters, and minimal bundle size.
consola
General JSElegant 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
npm install consolaUsage Example
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
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.