ColorLog

ColorLog

Prints colored console.log messages

Constructor

new ColorLog(params)

Initializes a ColorLog class

Source:
Parameters:
Name Type Description
params Object

Input parameters

Name Type Description
color string

ANSI color defined in ColorLog.COLORS

isBold boolean

Flag to render bold colored text

Members

COLORS :Object.<string, object>

ANSI colors for coloring the logging text.

Properties:
Properties
Name Type Description
TEXT Object

Object containing color properties.

Name Type Description
WHITE string

White color.

GRAY string

Gray color.

GREEN string

Green color.

RED string

Red color.

YELLOW string

Yellow color.

BLUE string

Blue color.

CYAN string

Cyan color.

RESET string

Reset color.

MAGENTA string

Magenta color.

Source:
Type:
  • Object.<string, object>

TEXT :Object.<string, string>

Text styles for logging.

Properties:
Name Type Description
BOLD string

Bold text style.

NORMAL string

Normal text style.

Source:
Type:
  • Object.<string, string>

(private) color :string

Text color

Source:
Type:
  • string

(private) log :string|null

Message log text.

Source:
Type:
  • string | null

(private) weight :string

Text weight (bold, normal)

Source:
Type:
  • string

Methods

log(message, options) → {boolean}

Prints colored log message in console.log()

Source:
Parameters:
Name Type Description
message string

Log message text

options Object

(Optional)

Name Type Description
color string

ANSI color defined in ColorLog.COLORS

isBold boolean

Flag to render bold colored text

Returns:
Type:
boolean

setColor(color) → {boolean}

Sets the text color in console.log()

Source:
Parameters:
Name Type Description
color string

ANSI color defined in ColorLog.COLORS

Returns:
Type:
boolean

setText(isBold) → {boolean}

Sets the text weight in console.log

Source:
Parameters:
Name Type Description
isBold boolean

Flag to render bold colored text

Returns:
Type:
boolean