Make log Colorful with Python

0xkoji - Jul 8 '19 - - Dev Community

install colorama

$ pip install colorama
Enter fullscreen mode Exit fullscreen mode

code

test.py

from colorama import Fore, Back, Style

print('===========================')
print(Fore.GREEN + "green string")
print(Style.DIM + "dim: test")
print(Style.BRIGHT + "BRIGHT: test")
print(Style.NORMAL + "NORMAL: test")
print(Style.RESET_ALL + "RESET_ALL")
print(Back.GREEN + 'green')
print(Style.RESET_ALL)
print('===========================')
print(Fore.RED + "red string")
print(Style.DIM + "dim: test")
print(Style.BRIGHT + "BRIGHT: test")
print(Style.NORMAL + "NORMAL: test")
print(Style.RESET_ALL + "RESET_ALL")
print(Back.RED + 'red')
print(Style.RESET_ALL)
print('===========================')
print(Fore.YELLOW + "yellow string")
print(Style.DIM + "dim: test")
print(Style.BRIGHT + "BRIGHT: test")
print(Style.NORMAL + "NORMAL: test")
print(Style.RESET_ALL + "RESET_ALL")
print(Back.YELLOW + 'yellow')
print(Style.RESET_ALL)
print('===========================')
print(Fore.BLUE + "blue string")
print(Style.DIM + "dim: test")
print(Style.BRIGHT + "BRIGHT: test")
print(Style.NORMAL + "NORMAL: test")
print(Style.RESET_ALL + "RESET_ALL")
print(Back.BLUE + 'blue')
print(Style.RESET_ALL)
Enter fullscreen mode Exit fullscreen mode

result

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .