render-colors
v1.0.2
Published
Minimal logging utility for both Node.js and browser consoles.
Readme
render-colors
A lightweight universal logging utility for Node.js and Browser environments — providing consistent, color-coded logs with zero configuration.
Features
- Works seamlessly in both Node.js and Browser
- Provides
success,error,warn,info, anddefaultlog levels - Automatically pretty-prints objects and arrays
- Clean ANSI colors in terminal, styled output in browser
- Zero dependencies, TypeScript support included
Installation
npm install render-colors
# or
yarn add render-colorsUsage
You can import the logger directly where you need it:
import { log } from 'render-colors';
log.success('Operation completed');
log.error('Something went wrong');
log.warn('This might be risky');
log.info('Fetching data...');
log('Plain message'); // default gray logIf you prefer a global logger available everywhere (no imports needed), just import the package once in your main entry file (e.g. main.ts or index.tsx):
import 'render-colors';
log.info('Global log works anywhere');Objects and arrays are automatically pretty-printed:
log.info({ user: 'ivan', balance: 1500 });
log.success(['BTC', 'ETH', 'SOL']);
API Reference
| Method | Description |
| ------------------- | --------------------------------------- |
| log(text, type?) | Base function (defaults to "default") |
| log.success(text) | Green background — success message |
| log.error(text) | Red background — error message |
| log.warn(text) | Yellow background — warning |
| log.info(text) | Blue background — informational message |
