Consola wraps console output for Node.js and browser environments with leveled logging, tags, and styled reporters. It can redirect standard console and std streams and includes optional interactive prompts.
Overview
Consola provides a console wrapper aimed at readable terminal and browser logging. It offers styled output with a fallback basic reporter when the environment is minimal or used in CI, and ships with built-in reporters for terminal and browser use.
Logging is organized by types and levels, from fatal errors through trace and verbose output, with throttling to reduce spam. You can add custom reporters, pause and resume log delivery, mock log types for tests, and scope messages with tags.
The package can globally redirect console methods and stdout or stderr to Consola handlers and restore them later. Interactive prompts support text, confirm, select, and multiselect flows via integration with clack.
Smaller core builds are available without the fancy reporter to reduce bundle size. Log level can be set on an instance or through a CONSOLALEVEL environment variable on supported Node builds.
Key features
- Leveled and typed log methods
- Pluggable custom reporters
- Fancy and basic reporter fallbacks
- Console and stdout/stderr redirection
- Tag-scoped logger instances
- Pause, resume, and mock logging
- Interactive CLI prompts
- Browser and Node.js support
Use cases
- Structured CLI application logging
- Test environments that mock console output
- Consistent log styling in Node tools
- Browser apps needing leveled logs