color-loggers

Print to console with colors.

MIT 8 个版本
安装
npm install color-loggers
yarn add color-loggers
pnpm add color-loggers
bun add color-loggers
README

color loggers

Print to console with colors.

Install

yarn add color-loggers

Use

import { Blue, Green, Red } from 'color-loggers';

const info = new Blue();
const success = new Green();
const error = new Red();

info.log('This is an information.');
success.log('Congratulations!');
error.log('Something is wrong!');

Sample output

Change the prefix

const info = new Blue('👉');
const success = new Green('🎉');
const error = new Red('⛔️');

info.log('This is an information.');
success.log('Congratulations!');
error.log('Something is wrong!');

Dynamic prefix

const info = new Blue(() => `[${new Date()}]:`);
info.log('This is an information.');

Output:

 [Thu Mar 02 2023 11:37:55 GMT-0800 (Pacific Standard Time)]: This is an information.

Choose another color

import { Color } from 'color-loggers';
import Styles from 'color-loggers/styles';

const logger = new Color(Styles.FgWhite, '');
logger.log('This is a white text.');

Disable logger

const logger = new Color(Styles.FgWhite, '');
logger.disable();
logger.log('This is a white text.'); // will not be printed
版本列表
0.3.2 2024-08-07
0.3.1 2024-07-21
0.3.0 2024-07-21
0.2.0 2023-03-31
0.1.3 2023-03-02
0.1.2 2023-03-02
0.1.1 2023-03-02
0.1.0 2023-03-02