first revision
This commit is contained in:
@@ -9,6 +9,19 @@ import shutil
|
||||
class Debug:
|
||||
_verbose = 0
|
||||
|
||||
_COLOR_RED = '\033[91m'
|
||||
_COLOR_BLUE = '\33[34m'
|
||||
_COLOR_GREEN = '\33[32m'
|
||||
_COLOR_YELLOW = '\033[93m'
|
||||
_COLOR_END = '\33[0m'
|
||||
|
||||
_FORMAT = { 'STANDARD': '',
|
||||
'ERROR': f'{_COLOR_RED}ERROR:{_COLOR_END} ',
|
||||
'NOTICE': f'{_COLOR_BLUE}NOTICE:{_COLOR_END} ',
|
||||
'WARNING': f'{_COLOR_YELLOW}WARNING:{_COLOR_END} ',
|
||||
'SUCCESS': f'{_COLOR_GREEN}SUCCESS:{_COLOR_END} '
|
||||
}
|
||||
|
||||
def __init__(self, verbose=0):
|
||||
self.set_verbose(verbose)
|
||||
|
||||
@@ -21,13 +34,19 @@ class Debug:
|
||||
def get_verbose(self):
|
||||
return self._verbose
|
||||
|
||||
def stdout(self, out, level=0):
|
||||
if self._verbose >= level:
|
||||
print(out)
|
||||
def stdout(self, out, verbose_level=0, category='STANDARD'):
|
||||
if self._verbose >= verbose_level:
|
||||
if category in self._FORMAT:
|
||||
print(f'{self._FORMAT[category]}{out}')
|
||||
else:
|
||||
print(f'[category {category} unknown]:{out}')
|
||||
|
||||
def stderr(self, out, level=0):
|
||||
if self._verbose >= level:
|
||||
print(str(out)+"\n", file=sys.stderr)
|
||||
def stderr(self, out, verbose_level=0, category='STANDARD'):
|
||||
if self._verbose >= verbose_level:
|
||||
if category in self._FORMAT:
|
||||
print(f'{self._FORMAT[category]}{out}', file=sys.stderr)
|
||||
else:
|
||||
print(f'[category {category} unknown]:{out}', file=sys.stderr)
|
||||
|
||||
|
||||
def get_config(filename, cfg):
|
||||
|
||||
Reference in New Issue
Block a user