1.0.9 • Published 5 months ago

charming-console v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago
## charming-log

Enhance your console output with colors, styles, symbols, and more!

Installation

npm install charming-console

Why charming-log?

  • Why have multiple packages, when you can have one?
  • Get rid of chalk, cli-spinners, console.table, time-stamp, and many others. We have you covered.
  • This package is constantly growing in features! What you need, we have. And if we don't have it, email us at support@logick.live

Usage

const {colorize, symbols, alignText, table, spin, createClickableLink, time} = require('charming-console');

// Colorize text
console.log(colorize('This is red text!', 'red'));
console.log(colorize('This is green text!', 'green'));
console.log(colorize('This is blue text!', 'blue'));

// Apply styles
console.log(applyStyle('Bold and italic text', 'bold,italic'));

// Display symbols
console.log(symbols.success, 'Operation successful!');
console.log(symbols.error, 'Error occurred!');
console.log(symbols.warning, 'Warning: proceed with caution!');
console.log(symbols.info, 'Information: check this out!');

// Align text
console.log(alignText('Right-aligned text', 'right'));
console.log(alignText('Center-aligned text', 'center'));

// Create a table
const data = [
  { name: 'John', age: 28, city: 'New York' },
  { name: 'Alice', age: 22, city: 'Los Angeles' },
  { name: 'Bob', age: 34, city: 'Chicago' },
];
console.log(table(data));

// Clickable link
console.log(createClickableLink('Click me!', 'https://example.com'));
console.log(createClickableLink('Click me!', 'https://example.com', 'green')); 
console.log(createClickableLink('Click me!', 'https://example.com', 'red', 'bold,underline'));
console.log(createClickableLink('Click me!', 'https://example.com', 'blue', 'white', 'bold,underline'));
console.log(createClickableLink('Click me!', 'https://example.com', '#FF0000', '#00FF00', 'bold,underline'));

//Spinners
//Spin forever
const forcast = spin('forcast');
//Spin for 5 seconds
const forcast = spin('forcast');
setTimeout(() => {
  clearInterval(forcast);
}, 5000);

//Timestamps
const formattedDate = time('YYYY-MM-DD HH:mm:ss', new Date());
console.log(formattedDate);
const timestamp = time();
console.log(timestamp);
const timestamputc = time.utc();
console.log(timestamputc);
const formattedUtcDate = time.utc('YYYY-MM-DD HH:mm:ss', new Date());
console.log(formattedUtcDate);

Features

Colorize

//Red Text
console.log(colorize('Red text', 'red'));
//Green text with a yellow background
console.log(colorize('Green text', 'green', 'yellow'));
console.log(colorize('Blue text', '#0000FF', '#FFFF00'));

Apply Styles

console.log(applyStyle('Bold and italic text', 'bold,italic'));
console.log(applyStyle('Underlined text', 'underline'));

Display Symbols

//Symbol Success `✓`
console.log(symbols.success, 'Operation successful!');
//Symbol Error `✗`
console.log(symbols.error, 'Error occurred!');
//Symbol Warning `⚠`
console.log(symbols.warning, 'Warning: proceed with caution!');
//Symbol Info `ℹ`
console.log(symbols.info, 'Information: check this out!');

Align Text

//Align Right
console.log(alignText('Right-aligned text', 'right'));
//Align Center
console.log(alignText('Center-aligned text', 'center'));

Create a Table

const data = [
  { name: 'John', age: 28, city: 'New York' },
  { name: 'Alice', age: 22, city: 'Los Angeles' },
  { name: 'Bob', age: 34, city: 'Chicago' },
];
console.log(table(data));

Interactive or clickable console output

// Basic usage, default color is blue
console.log(createClickableLink('Click me!', 'https://example.com'));

// Custom color and style
console.log(createClickableLink('Click me!', 'https://example.com', 'green', 'bold,underline'));

// Basic usage with text color and background color
console.log(createClickableLink('Click me!', 'https://example.com', 'blue', 'white', 'bold,underline,italic'));

// Custom text and background colors with style
console.log(createClickableLink('Click me!', 'https://example.com', '#FF0000', '#00FF00', 'bold,underline,italic'));

Spinners

//Spin Forever
const forcast = spin('forcast');
//Spin for 5 seconds
const forcast = spin('forcast');
setTimeout(() => {
  clearInterval(forcast);
}, 5000);

Timestamps

time(str, date, utc)

Formats a date object according to the provided format string.

  • str (string): The format string specifying how the date should be formatted.
  • date (Date, optional): The date object to format. Defaults to the current date.
  • utc (boolean, optional): If true, UTC time will be used. Defaults to false.

Returns: A formatted date string.

time.utc(str, date)

Same as time, but uses UTC time.

const formattedDate = time('YYYY-MM-DD HH:mm:ss', new Date());
console.log(formattedDate);

const formattedUtcDate = time.utc('YYYY-MM-DD HH:mm:ss', new Date());
console.log(formattedUtcDate);

Styles

Styles

StyleDescription
RESETResets all styles.
BRIGHTBright or bold text.
DIMDim or faint text.
UNDERLINEUnderlined text.
BLINKBlinking text.
REVERSEReversed background and foreground colors.
HIDDENHidden or invisible text.
ITALICItalicized text.

Colors

ColorDescription
BLACKBlack text.
REDRed text.
GREENGreen text.
YELLOWYellow text.
BLUEBlue text.
MAGENTAMagenta (purple) text.
CYANCyan (blue-green) text.
WHITEWhite text.
GRAYGray text.
BRIGHT_REDBright or light red text.
BRIGHT_GREENBright or light green text.
BRIGHT_YELLOWBright or light yellow text.
BRIGHT_BLUEBright or light blue text.
BRIGHT_MAGENTABright or light magenta (pink) text.
BRIGHT_CYANBright or light cyan text.
BRIGHT_WHITEBright or light white text.

Background Color

Background ColorDescription
BG_BLACKBlack background.
BG_REDRed background.
BG_GREENGreen background.
BG_YELLOWYellow background.
BG_BLUEBlue background.
BG_MAGENTAMagenta (purple) background.
BG_CYANCyan (blue-green) background.
BG_WHITEWhite background.
BG_GRAYGray background.
BG_BRIGHT_REDBright or light red background.
BG_BRIGHT_GREENBright or light green background.
BG_BRIGHT_YELLOWBright or light yellow background.
BG_BRIGHT_BLUEBright or light blue background.
BG_BRIGHT_MAGENTABright or light magenta (pink) background.
BG_BRIGHT_CYANBright or light cyan background.
BG_BRIGHT_WHITEBright or light white background.

Spinner Types

Explore a variety of spinners to add dynamic elements to your console output. Choose from the following spinner types:

Spinner TypeSpinner TypeSpinner TypeSpinner Type
1234
5678
lines1lines2arrowPipelilDots
scrollyDotsstaryxstarswaveFlip
spongebobupDownleftRightballoonPop
balloonPop2flashcornerBouncelineBounce
trianglebinarynoahsArcaround
squareCornerscircle25circle.5grid
toggleLinetogglesmBoxtogglebBoxtogglesbBox
toggleReqtargeteyearrowRound
arrowRightreboundingBarbounceBallsilly
peekaBoolovetimeearth
moonPhasetrackStarpingPongbabyShark
forcastsantabombfingy
booYahsoccercrazycolorPulse
load

Choose the spinner that suits your console output style and adds a touch of creativity!

Time Format Options

The format string can include the following placeholders:

PlaceholderDescription
YYYYFull year (4 digits).
YYShort year (2 digits).
MMMonth (zero-padded).
DDDay of the month (zero-padded).
HHHours (zero-padded).
mmMinutes (zero-padded).
ssSeconds (zero-padded).
msMilliseconds.

Questions, Comments, Support?

Send us an email at support@logick.live to create a ticket! Or join our Discord https://discord.com/invite/wNfFXx7J8q

License

This project is licensed under the MIT License

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago