Module: colorizer

Contains all of the functions needed to manage, parse and control font styles and font colors.

Author:
  • Seth Hollingsead
Source:

Requires

Methods

(inner) aggregateStyleSetting(settingValue1, settingValue2, defaultColorArray, processAsFontSetting) → {array.<boolean>}

Compares the two input settings and determines which one of them is valuable or not valuable.

Parameters:
Name Type Description
settingValue1 string

The file level setting from the configuration file.

settingValue2 string

The function level setting from the configuration file.

defaultColorArray array.<integer>

The default color value that should be used.

processAsFontSetting boolean

A True or False value to indicate if we are processing True = font setting, False = color setting.

Author:
  • Seth Hollingsead
Source:
Returns:

An array of booleans, [0] = underline setting True or False; [1] = bold setting True or False.

Type
array.<boolean>

(inner) colorizeMessage(message, className, functionName, debugFilesSetting, debugFunctionsSetting, flatMessageLog) → {string}

Applies color settings to various portions of the message according to the settings from the configuration system.

Parameters:
Name Type Description
message string

The message that should be formatted and returned to be logged to the console and/or logged to a log file.

className string

The name of the module/file that made the log call.

functionName string

The name of the function that made the log call.

debugFilesSetting boolean

A True or False value to indicate if the log should happen according to the file/module name. Setting is set in the configuration/settings system.

debugFunctionsSetting boolean

A True or False value to indicate if the log should happen according to the function/method name. Setting is set in the configuration/settings system.

flatMessageLog boolean

A True or False value to indicate if we are logging a flat message or if we should do additional processing. We will probably do some additional processing either way, but there is a difference in the workflows. For one a non-flat message will certainly have to replace a "%%" ith the class path (className,functionName), and the associated formatting that goes with that according to the settings.

Author:
  • Seth Hollingsead
Source:
Returns:

A colorized version of the message.

Type
string

(inner) colorizeMessageSimple(message, colorArray, isForeground) → {string}

Applies a color setting to an entire message, according to the inputs, background or foreground font color settings.

Parameters:
Name Type Description
message string

The message that should be formatted and returned according to the inputs, and controlled by the system configuration setting.

colorArray array.<integers>

The RGB color array that describes the color that should be applied to the message.

isForeground boolean

A True or False to indicate if the color setting should be applied to the foreground or not. If False, then apply to the background.

Author:
  • Seth Hollingsead
Source:
Returns:

The message with the color setting applied.

Type
string

(inner) getColorStyleSettingFromSetting(settingValue, defaultColorArray) → {object}

Parses the color setting to determine if the value should be parsed or loaded from the color data tables by unique color name.

Parameters:
Name Type Description
settingValue string

The setting value, which could be RGB as in R,G,B or it could be a string-name as in a unique color name.

defaultColorArray array.<integer>

The default color value that should be used.

Author:
  • Seth Hollingsead
Source:
Returns:

A JSON object with three integers that represent RGB values, labeled as "Red", "Green", "Blue".

Type
object

(inner) getFontStyleSettingsFromSetting(settingValue) → {array.<boolean>}

Parses the font setting to determine if values should be set for bold and/or underline.

Parameters:
Name Type Description
settingValue string

The setting value that should be parsed.

Author:
  • Seth Hollingsead
Source:
Returns:

An array of booleans, [0] = underline setting True or False; [1] = bold setting True or False.

Type
array.<boolean>

(inner) getNamedColorData(colorName, defaultColorArray) → {array.<integer>}

Queries the D-data structure for the named color data. All of this data should have been loaded from the Colors.csv file.

Parameters:
Name Type Description
colorName string

The name of the color who's RGB value we should look up from the color data structure.

defaultColorArray array.<integer>

The default color that should be used.

Author:
  • Seth Hollingsead
Source:
Returns:

An array of integers that represent RGB values.

Type
array.<integer>

(inner) removeFontStyles(message) → {string}

Removes all font styles and formatting from a string.

Parameters:
Name Type Description
message string

The string message that has formatting applied to it where the formatting should be removed: Example: BEGIN main program loop Return: BEGIN main program loop

Author:
  • Seth Hollingsead
Source:
Returns:

The string without all the extra formatting.

Type
string

(inner) setBoldFontStyleOnMessageComponentAccordingToSetting(messageComponent, boldSettingValue) → {string}

Examines the bold setting value and determines if the bold font setting should be applied to the message component or not.

Parameters:
Name Type Description
messageComponent string

The message to which the bold font setting should be applied if the setting value calls for it.

boldSettingValue boolean

A True or False value to indicate if the bold font setting should be applied or not applied.

Author:
  • Seth Hollingsead
Source:
Returns:

The same as the input string, except perhaps it might have a bold setting applied to it.

Type
string

(inner) setFontBackgroundColorOnMessageComponentAccordingToSetting(messageComponent, colorSettingValue) → {string}

Examines the color setting to determine if it is False, if not False then it is assumed to be an array of RGB values which are assigned to the message background using chalk.

Parameters:
Name Type Description
messageComponent string

The message to which the background color setting should be applied if the color setting value != false.

colorSettingValue boolean | array.<integer>

A value of False or an array of integers for RGB values. False if not color should be applied.

Author:
  • Seth Hollingsead
Source:
Returns:

The same as the input string, except perhaps it might have a background color setting applied to it.

Type
string

(inner) setFontForegroundColorOnMessageComponentAccordingToSetting(messageComponent, colorSettingValue) → {string}

Examines the color setting to determine if it is False, if not False then it is assumed to be an array of RGB values which are assigned to the message foreground component using chalk.

Parameters:
Name Type Description
messageComponent string

The message to which the foreground color setting should be applied if the color setting value != false.

colorSettingValue boolean | array.<integer>

A value of False or an array of integers for RGB values. False if no color should be applied.

Author:
  • Seth Hollingsead
Source:
Returns:

The same as the input string, except perhaps it might have a foreground color setting applied to it.

Type
string

(inner) setUnderlineFontStyleOnMessageComponentAccordingToSetting(messageComponent, underlineSettingValue) → {string}

Examines the underline setting value and determines if the underline font setting should be applied to the message component or not.

Parameters:
Name Type Description
messageComponent string

The message to which the underline font setting should be applied if the setting value calls for it.

underlineSettingValue boolean

A True or False value to indicate if the underline font setting should be applied or not applied.

Author:
  • Seth Hollingsead
Source:
Returns:

The same as the input string, except perhaps it might have an underline setting applied to it.

Type
string