-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlog.py
More file actions
28 lines (21 loc) · 1023 Bytes
/
log.py
File metadata and controls
28 lines (21 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from rich.console import Console
console = Console()
class log:
def progress(*args, **kwargs):
"""Print an informational message prefixed with `[*]`"""
console.print(r"\[[bright_blue]~[/bright_blue]]", *args, **kwargs)
def success(*args, **kwargs):
"""Print a successful message prefixed with `[+]`"""
console.print(r"\[[bright_green]+[/bright_green]]", *args, **kwargs)
def warning(*args, **kwargs):
"""Print a warning message prefixed with `[!]`"""
console.print(r"\[[bright_yellow]![/bright_yellow]]", *args, **kwargs)
def error(*args, exit_after=True, **kwargs):
"""Prints an error message prefixed with `[!]`. **Exits** after printing (unless `exit_after=False`)"""
console.print(r"\[[bright_red]![/bright_red]]", *args, **kwargs)
if exit_after: exit()
if __name__ == "__main__":
log.progress("Some information.")
log.success("Success! We did it!")
log.warning("Be warned...")
log.error("Oh no, an error!")