From 60defe0832ebbaa66c8145dbcba2547c31826c04 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 22 Oct 2020 18:25:49 +0200 Subject: [PATCH] Add custom log (print) functions --- src/util/log.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/util/log.py diff --git a/src/util/log.py b/src/util/log.py new file mode 100644 index 0000000..b563a13 --- /dev/null +++ b/src/util/log.py @@ -0,0 +1,37 @@ +import typing as t + +from src.util.color import Color + + +def question(question: str, options: t.Optional[list] = None) -> None: + """Print syntax for question with optional `options` to it""" + text = [f"{Color.GREEN} // {question}{Color.RESET}"] + if options: + for option in options: + text.append(f"{Color.GREEN} # {options}{Color.RESET}") + print("\n".join(text)) + + +def action(action: str) -> None: + """Print syntax for action""" + print(f"{Color.GOLD} >> {action}{Color.RESET}") + + +def err(text: str) -> None: + """Print syntax for error""" + print(f"{Color.RED} !! {text}{Color.RESET}") + + +def cancel(text: str) -> None: + """Print syntax for cancellation""" + print(f"{Color.GREY} >> {text}{Color.RESET}") + + +def comment(text: str) -> None: + """Print syntax for comments""" + print(f"{Color.GREY} // {text}{Color.RESET}") + + +def warning(text: str) -> None: + """Print syntax for warnings""" + print(f"{Color.YELLOW} ** {text}{Color.RESET}")