You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
580 B

from termcolor import colored
__all__ = ['log', 'warn', 'err', 'TestsError']
class TestsError(Exception):
pass
COLORS = {
'question': colored('[?]', 'magenta'),
'info': colored('[~]', 'green'),
'warning': colored('[!]', 'yellow'),
'error': colored('[X]', 'red'),
}
def warn(msg):
log(msg, log_lvl='w')
def err(msg):
log(msg, log_lvl='e')
def log(msg, log_lvl='i'):
for lvl, text in COLORS.items():
if lvl.startswith(log_lvl):
print(f'{text} {msg}')
break
else:
ValueError('Unknown log level')