🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

logpaint

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logpaint

Configure once, log everywhere — a lightweight colored logger for Node.js

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

logpaint

Configure once, log everywhere.

A lightweight, zero-dependency colored logger for Node.js with full TypeScript support. Custom log levels, timestamps, level filtering, and runtime switching — all in one tiny package.

npm version npm downloads license node

Website · npm · Report a Bug

Table of Contents

Why logpaint?

Most logging libraries are designed for production-grade infrastructure — they're heavy, complex, and need configuration files, transports, and plugins just to get colored output.

logpaint does one thing well: it gives your Node.js app beautiful, colored console logs with a single function call. No config files. No transports. No dependencies. Just install, call createLogger(), and your terminal comes to life.

Featurelogpaintchalkwinstonpino
Zero dependencies
Built-in log levels
Custom levels (typed)
Level filtering
Runtime level switching
ESM + CJS
TypeScript generics

Features

  • Zero runtime dependencies — pure Node.js, nothing to audit or update
  • 5 built-in levelsdebug, info, success, warn, error — ready out of the box
  • Custom log levels — add http, db, query, or anything else, fully typed in TypeScript
  • Timestamps — enable with a single flag (YYYY-MM-DD HH:MM:SS format)
  • Level filtering — set minLevel to suppress noise in production
  • Runtime switching — change log level on the fly with setLevel(), no restart needed
  • TypeScript generics — custom level methods get full IntelliSense autocomplete
  • Dual CJS + ESM — works with import and require() out of the box

Installation

# npm
npm install logpaint

# yarn
yarn add logpaint

# pnpm
pnpm add logpaint

Requirements: Node.js ≥ 14

Quick Start

import { createLogger } from 'logpaint';

const log = createLogger();

log.info('Server started on port 3000');
log.success('Database connected');
log.warn('Deprecated API endpoint used');
log.error('Failed to read config file');
log.debug('Request payload: { id: 42 }');

Output (colors rendered in your terminal):

[INFO]    Server started on port 3000
[SUCCESS] Database connected
[WARN]    Deprecated API endpoint used
[ERROR]   Failed to read config file
[DEBUG]   Request payload: { id: 42 }

With Timestamps

Pass timestamp: true to prepend a YYYY-MM-DD HH:MM:SS timestamp to every log line.

import { createLogger } from 'logpaint';

const log = createLogger({ timestamp: true });

log.info('Request received');
log.success('Response sent in 42ms');
log.error('Connection timeout');
2026-02-22 10:30:45 [INFO]    Request received
2026-02-22 10:30:45 [SUCCESS] Response sent in 42ms
2026-02-22 10:30:45 [ERROR]   Connection timeout

Log Level Filtering

Set minLevel to suppress all logs below a certain priority. Useful for silencing debug/info noise in production.

import { createLogger } from 'logpaint';

const log = createLogger({ minLevel: 'warn' });

log.debug('Hidden');   // suppressed — priority 0 < 2
log.info('Hidden');    // suppressed — priority 1 < 2
log.warn('Visible');   // shown — priority 2 ≥ 2
log.error('Visible');  // shown — priority 3 ≥ 2

Default Priority Table

LevelColorPriority
debugmagenta0
infocyan1
successgreen1
warnyellow2
errorred3

Custom Levels

Add your own log levels with custom colors, prefixes, and priorities. They're fully typed — TypeScript will give you autocomplete on log.http(), log.db(), etc.

import { createLogger } from 'logpaint';

const log = createLogger({
  timestamp: true,
  levels: {
    http: { color: 'brightBlue' },
    db:   { color: 'brightMagenta', prefix: 'DATABASE' },
  },
});

log.http('GET /api/users 200 OK');
log.db('Query executed in 12ms');
log.info('Default levels still work');
2026-02-22 10:30:45 [HTTP]     GET /api/users 200 OK
2026-02-22 10:30:45 [DATABASE] Query executed in 12ms
2026-02-22 10:30:45 [INFO]     Default levels still work

You can also pass a color name directly as a shorthand:

import { createLogger } from 'logpaint';

const log = createLogger({
  levels: {
    http: 'brightBlue',
    db:   'brightMagenta',
  },
});

Runtime Level Switching

Change the minimum log level at any point during execution using setLevel(). No process restart needed — useful for toggling verbose output in long-running servers.

import { createLogger } from 'logpaint';

const log = createLogger();

log.info('Visible');        // shown

log.setLevel('error');      // from now on, only show errors

log.info('Hidden');         // suppressed
log.error('Visible');       // shown

CommonJS Usage

logpaint ships both ESM and CJS builds. Use require() if you're not using ES modules.

const { createLogger } = require('logpaint');

const log = createLogger({ timestamp: true });

log.info('Works with require() too');
log.success('CJS + ESM — your choice');

Full working examples: Node.js · NestJS

Available Colors

Use any of these color names in color fields for built-in or custom levels.

BasicBright
blackbrightBlack
redbrightRed
greenbrightGreen
yellowbrightYellow
bluebrightBlue
magentabrightMagenta
cyanbrightCyan
whitebrightWhite

API Reference

createLogger(config?)

Creates and returns a logger instance. All built-in level methods and any custom level methods are available on the returned object.

Config Options

OptionTypeDefaultDescription
timestampbooleanfalsePrepend YYYY-MM-DD HH:MM:SS to each log
minLevelstringundefinedMinimum priority level to display
levelsRecord<string, ANSIColor | LevelConfig>undefinedCustom levels to add alongside built-ins

LevelConfig

FieldTypeDefaultDescription
colorANSIColorrequiredANSI color name for this level
prefixstringlevel name (uppercase)Label shown in brackets, e.g. [DB]
prioritynumber1Priority used for minLevel filtering

Logger Methods

MethodDescription
log.debug(...args)Log at debug level (priority 0)
log.info(...args)Log at info level (priority 1)
log.success(...args)Log at success level (priority 1)
log.warn(...args)Log at warn level (priority 2)
log.error(...args)Log at error level (priority 3)
log.setLevel(level)Change minimum log level at runtime

Contributing

Contributions, bug reports, and feature requests are welcome.

  • Fork the repository
  • Create a branch: git checkout -b feat/your-feature
  • Make your changes and run npm test
  • Open a pull request

Please open an issue first for large changes so we can discuss the approach.

License

MIT © Sounak Das

Keywords

logger

FAQs

Package last updated on 27 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts