CrowdStrike Falcon CrowdStrike Subreddit

Colorize text output

Documentation Version Page Updated

This helper provides developers with a simple class that can be leveraged to add color to terminal text output by providing standard ANSI escape sequences as attributes.

The Color class was first introduced in FalconPy v1.5.1.

Supported colors

This function provides support for the following ANSI colors.

Text Color List

Support for BOLD and UNDERLINE is also provided.

Attributes

This class provides the following attributes.

AttributeReturns
PURPLE\033[95m
CYAN\033[96m
DARKCYAN\033[36m
MAGENTA\033[35m
BLUE\033[34m
LIGHTBLUE\033[94m
GREEN\033[32m
LIGHTGREEN\033[92m
LIGHTYELLOW\033[93m
YELLOW\033[33m
RED\033[31m
LIGHTRED\033[91m
BOLD\033[1m
UNDERLINE\033[4m
END\033[0m

To prevent bleed, END is used to close the colorized text block and should always be provided.

Adding color to text output

Class attributes are returned as strings, meaning they can be interpolated directly into strings intended for terminal output.

Code example

from falconpy import Color
result = f"This string contains {Color.RED}red {Color.BOLD}bold{Color.END} text"
print(result)

Output example

Red Bold text example