JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1612
  • Score
    100M100P100Q110887F
  • License MIT

Colorful `console.log` for structured logging.

Package Exports

  • clrsole
  • clrsole/dist/index.js
  • clrsole/dist/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (clrsole) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

clrsole

npm package

NPM version NPM Downloads

Colorful console.log for structured logging
A logging utility with log levels and color highlighting inspired by log4j


Features

  • 🎨 Colorized output: Green/Red/Yellow/Blue for different message types
  • 📝 6-level logging: trace/debug/info/warn/error/fatal
  • 🛠 Flexible formatting: Customize log message templates
  • 🌐 TypeScript support: Full type definitions included

Installation

npm install clrsole

Getting Started

Basic Usage

import { factory, clrsole } from 'clrsole';

// Create named logger
const appLogger = factory.getLogger('app');

// Structured logging with level indicators
appLogger.info('User login success:', { userId: 123, timestamp: new Date() });
appLogger.error('Request failed:', { statusCode: 500 });

// Direct color output
clrsole.green('Success message');
clrsole.red('Error occurred', new Error('Detailed error'));

Output Example

\x1b[32m[2023-08-01 10:00:00.620+08:00] [INFO] [app] - User login success: { userId: 123, ... }\x1b[0m
\x1b[31m[2023-08-01 10:01:00.620+08:00] [ERROR] [app] - Request failed: { statusCode: 500 }\x1b[0m

Advanced Features

Level Control

// Only log warnings and above
appLogger.level = 'WARN';

Contributing

We welcome contributions from the community! If you find a bug or want to suggest an improvement, feel free to open an issue or submit a pull request.

How to Contribute

  1. Fork the repository.
  2. Create a new branch for your changes.
  3. Submit a pull request with a clear description of your changes.

License

This project is licensed under the MIT License.