Added log.debugl(LEVEL, msg) function, using verbose level

- Not using logging values
This commit is contained in:
Salvador E. Tropea 2022-06-18 16:35:31 -03:00
parent 64ca09af50
commit d2c607755f
2 changed files with 14 additions and 1 deletions

View File

@ -240,7 +240,7 @@ def main():
# Set the specified verbosity
GS.debug_enabled = log.set_verbosity(logger, args.verbose, args.quiet)
GS.debug_level = args.verbose
log.debug_level = GS.debug_level = args.verbose
# Now we have the debug level set we can check (and optionally inform) KiCad info
detect_kicad()

View File

@ -29,6 +29,7 @@ domain = 'kilog'
filters = None
root_logger = None
visual_level = None
debug_level = 0
def get_logger(name=None):
@ -107,6 +108,18 @@ class MyLogger(logging.Logger):
else:
super(self.__class__, self).debug(msg, *args, **kwargs)
def debugl(self, level, msg, *args, **kwargs):
# Similar to log() but using the debug_level (-vvvv) instead of the Python level
global debug_level
if level > debug_level:
return
if isinstance(msg, tuple):
msg = ' '.join(map(str, msg))
if sys.version_info >= (3, 8):
super(self.__class__, self).debug(msg, stacklevel=2, *args, **kwargs) # pragma: no cover (Py38)
else:
super(self.__class__, self).debug(msg, *args, **kwargs)
def log_totals(self):
if MyLogger.warn_cnt:
filt_msg = ''