-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLogger.py
More file actions
40 lines (31 loc) · 1.32 KB
/
Copy pathLogger.py
File metadata and controls
40 lines (31 loc) · 1.32 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
import html
from InquirerPy.utils import get_style
from prompt_toolkit import print_formatted_text, HTML
class Logger:
@staticmethod
def e(message):
return html.escape(str(message))
@staticmethod
def s(message, style_name):
style = get_style().dict.get(style_name, '#abb2bf')
return f'<style fg="{style}">{Logger.e(message)}</style>'
@staticmethod
def success(message):
print_formatted_text(HTML(f"{Logger.s('[OK]', 'input')} {message}"))
@staticmethod
def error(message, err=None):
error_details = f": {err}, {type(err)}" if err else ""
print_formatted_text(HTML(Logger.s(f'[ERROR] {message}{error_details}', 'fuzzy_prompt')))
@staticmethod
def warning(message):
print_formatted_text(HTML(f"{Logger.s('[WARNING]', 'marker')} {message}"))
@staticmethod
def info(message):
print_formatted_text(HTML(f"[INFO] {message}"))
@staticmethod
def page_separator(page_num):
print_formatted_text(HTML(Logger.s(f'[------------------------ PAGE {page_num} END ------------------------]', 'input')))
print()
@staticmethod
def page_header(page_num):
print_formatted_text(HTML(Logger.s(f'[------------------------ LOAD {page_num} END ------------------------]', 'input')))