| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- from functools import wraps
- import time
- def cprint(text_in: str, color: str):
- """[summary]
- Args:
- text_in (str): Any text string you want to print.
- color (str): 'dark_gray', 'r', 'g', 'y', 'b', 'p', 'c', 'gray'
- """
- color_dict = {'dark_gray': '30', 'r': '31', 'g': '32',
- 'y': '33', 'b': '34', 'p': '35', 'c': '36', 'gray': '37'}
- header = f'\033[1;{color_dict[color]}m'
- end = '\033[0m'
- print(header+text_in+end)
- def cstr(text_in: str, color: str):
- """[summary]
- Args:
- text_in (str): Any text string you want to return with color.
- color (str): 'dark_gray', 'r', 'g', 'y', 'b', 'p', 'c', 'gray'
- """
- color_dict = {'dark_gray': '30', 'r': '31', 'g': '32',
- 'y': '33', 'b': '34', 'p': '35', 'c': '36', 'gray': '37'}
- header = f'\033[1;{color_dict[color]}m'
- end = '\033[0m'
- return header+text_in+end
- INFO = "INFO"
- WARNING = "WARNING"
- ERROR = "ERROR"
- STATUS = "STATUS"
- def log_print(p_type: str, text_in):
- """Print colorful log message on screen
- Args:
- p_type (str): Three types: INFO, WARNING, ERROR
- text_in (str): Any text message you want to print.
- """
- type_dict: dict = {"INFO": 'y', "WARNING": 'b',
- "ERROR": 'r', "STATUS": 'c'}
- cprint('\n'+p_type+': '+text_in, type_dict[p_type])
|