Logger is now an attribute of the execution context

This commit is contained in:
2020-02-18 16:31:55 +01:00
parent 86c2ff58d4
commit 87f232b527
27 changed files with 213 additions and 243 deletions
+19 -8
View File
@@ -2,21 +2,32 @@ import logging
import sys
enabled = []
disabled = ["init", "sdp", "parsers", "evaluators", "verbose"]
disabled = ["init", "sdp", "parsers", "evaluators", "verbose", "stats"]
console_handler = logging.StreamHandler(sys.stdout)
all_loggers = {}
def set_enabled(to_enable):
if to_enable is None:
def init_config(loggers):
if loggers is None:
return
if not hasattr(to_enable, "__iter__"):
to_enable = [to_enable]
if not hasattr(loggers, "__iter__"):
loggers = [loggers]
enabled.extend(to_enable)
if "all" in loggers:
disabled.clear()
for logger in loggers:
if logger == "all":
continue
if logger.startswith("-"):
disabled.append(logger[1:])
elif logger.startswith("+"):
enabled.append(logger[1:])
else:
enabled.append(logger)
def to_discard(logger_class):
@@ -40,7 +51,7 @@ def get_logger(logger_name):
all_loggers[logger_name] = logger
for d in disabled:
if logger_name.startswith(d + ".") and to_discard(d):
if (logger_name == d or logger_name.startswith(d + ".")) and to_discard(d):
logger.disabled = True
for e in enabled: