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.
- π¨ 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
- Node.js 14.0.0 or higher
npm install charmlog// 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');// 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 colored text
charmlog.rainbow('This text will be rainbow colored!');// 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');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');const obj = {
name: 'John',
age: 30,
hobbies: ['coding', 'reading'],
address: {
city: 'New York',
country: 'USA'
}
};
charmlog.dir(obj);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 resultimport { colors } from 'charmlog';
// Access individual color methods
colors.red('This is red');
colors.green('This is green');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 settingsimport { 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();The library includes full TypeScript support with comprehensive type definitions.
CharmLog is compatible with:
- Rollup
- Webpack
- Vite
- esbuild
- Parcel
// Only import what you need
import { red, green } from 'charmlog';
import { Logger } from 'charmlog';We welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/antisedativ/CharmLog.git
cd CharmLog
npm install
npm run build
npm testMade with β€οΈ by the Charmlog