npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hipstersantos/colorful-logger

v1.2.9

Published

A self-adaptive colorful logging library for Node.js, React, and browsers with ESM and CommonJS support

Downloads

86

Readme

@hipstersantos/colorful-logger

A lightweight, colorful logging utility for Node.js and browser environments, supporting both CommonJS and ESM. Ideal for debugging, monitoring, and production logging with customizable output.

GitHub Repository | npm Package

npm version


🚀 Features

  • 🎨 Color-Coded Logs: Info (blue), Debug (cyan), Warning (yellow), Error (red), Critical (white on red).
  • 📊 Stack Tracing: Includes caller information and full stack traces for better debugging.
  • ⚙️ Customizable: Toggle timestamps, caller info, and environment-specific behavior.
  • 🌐 Universal Compatibility: Supports CommonJS (require) and ESM (import).
  • 🛡️ Error Monitoring: Captures uncaught exceptions and unhandled promise rejections globally.
  • 🔍 Dynamic Import: Supports lazy loading for performance optimization.
  • 📝 Metadata Support: Enhance logs with objects, arrays, or custom data.
  • 📦 Memory-Safe: Prevents event listener leaks with single-instance global handlers.
  • 🖥️ Browser-Friendly: Uses collapsible console groups for complex metadata.

📥 Installation

Install via npm:

npm install @hipstersantos/colorful-logger

Or via Yarn:

yarn add @hipstersantos/colorful-logger

📚 Usage

CommonJS

const Logger = require('@hipstersantos/colorful-logger');

const log = new Logger('MyApp');
log.info('Server started');
log.debug('User request', { userId: 123 });
log.error('Something went wrong', new Error('Oops'));

// Cleanup (optional, recommended for long-running apps)
log.destroy();

ES Module (ESM)

import Logger from '@hipstersantos/colorful-logger';

const log = new Logger('MyApp');
log.info('Server started');
log.debug('User request', { userId: 123 });
log.error('Something went wrong', new Error('Oops'));

// Cleanup
log.destroy();

Dynamic Import (Lazy Loading)

const logger = await Logger.dynamicImport('DynamicApp');
logger.info('Loaded dynamically');

⚙️ Configuration Options

Customize your logger:

const log = new Logger('CustomApp', {
  showTimestamp: false, // Hide timestamps
  showCaller: false,    // Hide caller info
  env: 'production',    // Suppress debug logs in production
});

| Option | Type | Default | Description | |---------------------|----------|---------------|--------------------------------------------| | showTimestamp | Boolean | true | Display timestamps in log messages. | | showCaller | Boolean | true | Display the caller function info. | | env | String | development | Environment mode (e.g., 'production'). | | exitOnError | Boolean | true | Exit process on errors (Node.js only). | | suppressBrowserErrors | Boolean | false | Suppress errors in the browser console. | | dynamicImport | Boolean | false | Enable lazy loading (CommonJS only). |


📊 API Reference

Methods

| Method | Description | |---------------------------|---------------------------------------------| | info(message, meta) | Logs an informational message (blue). | | debug(message, meta) | Logs a debug message (cyan). | | warning(message, meta) | Logs a warning message (yellow). | | error(message, meta) | Logs an error message (red) with stack trace.| | critical(message, meta) | Logs a critical message (red background). | | destroy() | Cleans up event listeners and global tracking.| | getLogger(name, options)| Creates or retrieves a logger instance. | | dynamicImport(name) | Lazily loads a logger (CommonJS only). |


📜 Changelog

v1.2.8 (March 07, 2025)

Memory Leak Prevention:

  • Global error handlers (uncaughtException, unhandledRejection) are now registered only once, preventing listener accumulation.
  • Introduced destroy() method to remove logger instances and clean up global event listeners.

Robustness:

  • Fixed handling of null metadata to prevent errors when accessing stack.

Compatibility:

  • Fully backward-compatible with previous versions.

v1.2.7

  • Fixed import.meta usage in .cjs files, ensuring proper CommonJS compatibility.
  • Improved consistency by adding a local package.json in examples.

v1.2.6

  • Initial memory leak fix for MaxListenersExceededWarning.
  • Enhanced module type detection.

🛠️ Best Practices

  • Cleanup: Call logger.destroy() in long-running applications to free resources.
  • Intervals: Clear intervals or timeouts (e.g., clearInterval) to prevent memory leaks.
  • Production: Set env: 'production' to suppress debug logs automatically.

📊 Examples

Explore comprehensive usage examples in the examples directory:

  • usage.js - CommonJS example.
  • usage.mjs - ESM example.

✅ Testing

Run the test suite:

npm test

📜 License

Licensed under the MIT License.