Replace scattered console.log calls in a Node.js app with leveled, colored log output that silences itself in CI environments.
Write a custom reporter that formats log lines as JSON and sends them to a log aggregation service without changing the rest of your code.
Mock all log output during automated tests so that test output stays clean and assertions are not cluttered with debug messages.
Consola is a logging library for JavaScript applications running in Node.js or the browser. Instead of using the built-in console directly, you route your log calls through Consola, which then formats and displays them in a cleaner way. It works in both server-side and browser environments and ships with a colored, styled output by default, falling back to a simpler format in testing or CI environments where fancy output would be noise. The library supports multiple log levels, from fatal errors down to verbose debug traces. You pick which level is visible at runtime, so a production app might show only warnings and errors while a development session shows everything. Each level has its own method, like consola.info(), consola.warn(), consola.success(), and consola.error(), giving log lines a consistent look without extra formatting code. Beyond basic logging, Consola lets you pause and resume log output, tag log messages with a label so you can trace which part of a system a message came from, and mock all log calls during tests so automated test output stays clean. It also integrates with interactive terminal prompts, letting you ask the user a yes/no question or display a selection menu from the same logger instance. One of its notable design points is the reporter system. By default Consola uses its built-in reporters, but you can swap or add your own. A custom reporter is just an object with a log method, so you could write one that sends logs to a file, formats them as JSON, or exits the process on fatal errors. This makes the library adaptable without requiring changes to the rest of your code. Consola also offers smaller build variants for projects where bundle size matters. You can import from consola/basic or consola/core to skip the fancy terminal styling and reduce the footprint by roughly 80 percent.
← unjs on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.