Node.js Log Utility

2.3.0 · maintenance · verified Sun Apr 19

log-util is a minimalist Node.js logging utility designed for terminal output. It provides a simple API for common log levels such as debug, info, success, warn, and error, allowing developers to categorize and display messages with distinct visual feedback in the console. The current stable version is 2.3.0. The package appears to be in a maintenance or stable state, with its last publish date being approximately six years ago (as of April 2026), indicating a lack of recent active development or frequent feature additions. Its primary differentiator is its simplicity and small footprint, offering basic logging capabilities without the extensive configuration or advanced features found in more comprehensive logging frameworks. It ships with TypeScript type definitions, enabling a typed development experience for users.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates importing `log-util`, setting the global log level, using various logging methods, and creating a separate `Log` instance with its own level.

import log from 'log-util';

// Set the global log level to 'info'
log.setLevel('info');

console.log('--- Default Logger (Level: Info) ---');
log.debug('This is a debug message (should not appear)');
log.info('This is an info message (level: 1)', { user: 'Alice' });
log.success('Operation completed successfully (level: 2)');
log.warn('A warning occurred (level: 3)');
log.error('An error happened (level: 4)', new Error('Something went wrong'));

// Create a new Log instance with a custom level
// The 'Log' constructor is exposed on the default 'log' object
const customLogger = new log.Log(log.levels.debug);

console.log('\n--- Custom Logger (Level: Debug) ---');
customLogger.setLevel('debug'); // Set instance level to debug
customLogger.debug('This is a debug message from custom logger (level: 0)');
customLogger.info('Info from custom logger (level: 1)', [1, 2, 3]);
customLogger.success('Success from custom logger (level: 2)');

// Demonstrate changing level mid-execution
console.log('\n--- Changing Level on Default Logger ---');
log.setLevel('error');
log.info('This info message will not appear now.');
log.error('Only error messages will show (level: 4) after changing level.');

view raw JSON →