Skip to content

Make your terminal string output even more beautiful πŸ’–

License

Notifications You must be signed in to change notification settings

antisedative/CharmLog

Repository files navigation

CharmLog 🎨

Check GitHub code size in bytes npm npm version License

Make your terminal string output even more beautiful πŸ’–

A modern, lightweight logging library for Node.js that provides beautiful colored output, rainbow text, custom formatting, and structured logging capabilities.

✨ Features

  • 🎨 Rich Color Support - 16 basic colors with bright variants
  • 🌈 Rainbow Text - Multi-colored text output
  • πŸ“ Custom Formatting - printf-style formatting with colors and styles
  • πŸ“Š Structured Logging - Logger class with log levels
  • πŸ” Object Inspection - Beautiful object/array visualization
  • 🎯 TypeScript Support - Full type definitions included
  • πŸ“¦ Tree-shakable - Only import what you need
  • πŸš€ Zero Dependencies - Lightweight and fast

πŸ“¦ Installation

Prerequisites

  • Node.js 14.0.0 or higher

Install

npm install charmlog

πŸš€ Quick Start

// ES Modules
import charmlog from 'charmlog';

// CommonJS
const charmlog = require('charmlog').default;

// Basic usage
charmlog.blue('Hello, World!');
charmlog.rainbow('This is a rainbow text!');
charmlog.printf('Custom formatted text');

πŸ“š API Reference

Basic Colors

// Basic colors
charmlog.red('Error message');
charmlog.green('Success message');
charmlog.yellow('Warning message');
charmlog.blue('Info message');
charmlog.magenta('Debug message');
charmlog.cyan('Trace message');
charmlog.white('Normal message');
charmlog.black('Dark message');

Rainbow Text

// Rainbow colored text
charmlog.rainbow('This text will be rainbow colored!');

Custom Formatting

// Set formatting options
charmlog.settings.color = '#ff0000';
charmlog.settings.backgroundColor = '#000000';
charmlog.settings.fontWeight = 'bold';
charmlog.settings.style = 'italic';

// Apply formatting
charmlog.printf('Custom formatted text');

Structured Logging

import { Logger } from 'charmlog';

const logger = new Logger('info');

logger.debug('Debug message');
logger.info('Info message');
logger.warning('Warning message');
logger.error('Error message');
logger.critical('Critical message');

Object Inspection

const obj = {
  name: 'John',
  age: 30,
  hobbies: ['coding', 'reading'],
  address: {
    city: 'New York',
    country: 'USA'
  }
};

charmlog.dir(obj);

Core Functions

import { charmprint, createCharmedObject } from 'charmlog';

// Wrap any function to auto-log its output
const wrappedFn = charmprint((a, b) => a + b);
wrappedFn(2, 3); // Logs: 5

// Create a charmed object
const myObj = createCharmedObject({
  greet: (name) => `Hello, ${name}!`
});
myObj.greet('World'); // Auto-logs the result

🎯 Advanced Usage

Custom Color Methods

import { colors } from 'charmlog';

// Access individual color methods
colors.red('This is red');
colors.green('This is green');

Logger Configuration

import { Logger } from 'charmlog';

const logger = new Logger('warning', true); // Only show warnings and above

logger.setLogLevel('error'); // Change log level
logger.reset(); // Reset to default settings

Settings Management

import { settings } from 'charmlog';

// Configure text formatting
settings.color = '#ff0000';
settings.backgroundColor = 'transparent';
settings.fontWeight = 'bold';
settings.style = 'normal';
settings.textDecoration = 'underline';

// Reset all settings
settings.reset();

πŸ”§ Configuration

TypeScript

The library includes full TypeScript support with comprehensive type definitions.

Build Tools

CharmLog is compatible with:

  • Rollup
  • Webpack
  • Vite
  • esbuild
  • Parcel

Tree Shaking

// Only import what you need
import { red, green } from 'charmlog';
import { Logger } from 'charmlog';

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

git clone https://github.com/antisedativ/CharmLog.git
cd CharmLog
npm install
npm run build
npm test

Made with ❀️ by the Charmlog

About

Make your terminal string output even more beautiful πŸ’–

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6