Overview
ColoLog is a small logging utility for Node.js (and browser) JavaScript that wraps console.log with color-coded, leveled output. It's built on top of chalk and gives each log level its own color, so you can scan a noisy terminal and immediately tell warnings from errors from routine info lines.
It's intentionally minimal — a single Logger class with no config file, no transports, and one dependency. The target audience is small Node.js scripts and side projects that want more readable console output than plain console.log, without adopting a full logging framework like Winston or Pino.
Key Features
- Four log levels —
log(green),info(blue),warn(yellow),error(red), each mapped to a distinct chalk color - Timestamped output — every line is stamped with the current time via
Date().toLocaleString() - Optional instance prefix — pass a name to the constructor (e.g.
new Logger('MyApp')) to tag every line from that logger, useful when multiple modules log to the same console - Single dependency — just
chalk, keeping the install footprint small
Installation
npm install colologyarn add colologUsage
const CustomLogger = require('cololog');
// Create a new instance of the logger
const logger = new CustomLogger('MyApp');
// Log messages to the console
logger.log('This is a log message.');
logger.info('This is an info message.');
logger.warn('This is a warning message.');
logger.error('This is an error message.');Each call prints a line in the form [<timestamp>] [<LEVEL>] [<prefix>]: <message>, colored according to the level. The prefix segment is omitted if the logger was constructed without one.